Google BigQuery VS Oracle SQL Comparison [Partitioned table]

 Introduction to clustered tables


There are 2 types of creating ways for a table in Google BigQuery. 


1. Partitioned table

2. Clustered table 

*Clustered? Close group

Clustered tables in BigQuery are tables that have a user-defined column sort order using clustered columns. Clustered tables can improve query performance and reduce query costs.


What is an index?

An index is a database structure that provides a quick lookup of data in a column or columns of a table.

For example, a Flights table in a travel DB database has three indexes:
  • An index on the orig_airport column (called OrigIndex)
  • An index on the dest_airport column (called DestIndex)
  • An index enforcing the primary key constraint on the flight_id and segment_number columns (which have a system-generated name)


Statement to create an index in Oracle

: an index will provide a quick lookup data structure or column of data set. 
: Google BigQuery does not provide an index statement in a clustered table 


1_) Create index index name on Table name
2_) Create index Index name_Tablename on Table name(Column name)




What is a Clustered table?

1. Cluster table이란
- Cluster table은 여러 테이블에서 동일한 키를 가진 데이타를 데이터베이스에서
하나의 물리적은 데이블로 생성 관리한다.
즉 tab1 과 tab2 가 각각 같은 key값을 가지는 table로 구성되어 있으면 하나의
물리적인 Table로 관리할 수 있다

2. Table의 구성
- Cluster Table의 field는 각각의 table에서 공통되는 Key field가 각각
Primary key field로 존재하며 non-key field는 Pool table과 마찬가지로 VARDATA란 field에 일괄적으로 등록되어 관리되게 된다.
ex) SAP에서 Cluster Table : INDX, RFBLG 등등.

3. Cluster table의 특징
- Primary key가 사용될 경우 검색속도는 매우 빠르다
- 만약 non-key field을 사용하여 클러스터 table을 쿼리하면 검색속도는 매우
느려진다.
- Cluster table은 데이타가 패기지 단위로 처리될때 빠른 속도를 지원한다.


4. 클러스터 테이블의 사용시 고려사항.
- Cluster table에 index를 생성하는 것은 불가능하다.
- column selection하는 것은 가능하나 시스템은 항상 레코드 전체를 Access한다
(non-key field는 VARDATA에 존해하기 때문)
- SUM,AVG,MIN,MAX 같은 함수들을 사용할 수 없다
- Buffering이 지원되지 않는다.
- External program은 클러스터 table의 data를 핸들링할수 없다
(Pool table도 마찬가지임)
- 특수한 목적을 제외하고는 새로운 Table을 정의할때에는 클러스터 타입으로 정의하지 말것.





Comments