Using Hydra Columnar
Should I use a row or columnar table?
Please see our documentation about when to use row and columnar tables.
Enabling Columnar
For Hydra Cloud databases, columnar is already enabled.
For Hydra open source, the default postgres
database has columnar enabled. Additional databases you create need to have columnar enabled by running the query below as superuser:
Once installed, you will not need superuser to utilize columnar tables.
Using a columnar table
Hydra supports both columnar and traditional Postgres row-based (heap
) tables. Columnar is the default type of table created on Hydra.
You can explicitly create either a row-based or columnar table by adding the USING
keyword:
Once created, the table operates like a normal Postgres table. You can SELECT, INSERT, UPDATE, DELETE, and ALTER TABLE like you would expect, with a few restrictions:
Columnar does not support logical replication. Creating a subscription on a columnar table will cause any writes to that table to return an error.
Foreign keys are not supported.
Indexing may cause some queries to run slower; in many cases, indexes are not necessary. For more information, please read our documentation on using indexes.
BRIN indexes are not supported.
Converting From Row to Columnar
Hydra has a convenience function that will copy tables between row and columnar:
Data can also be converted manually by copying. For instance:
Default table type
The default table type for the default database is columnar
. You can change this using an ALTER DATABASE
statement:
For any database you create manually with CREATE DATABASE
, the default table type is heap
.
The name of the default database on Hydra Cloud can be found with your credentials in the Hydra Dashboard. With Hydra Open Source, the default database is postgres
.
Partitioning
Columnar tables can be used as partitions. A partitioned table may be made up of any combination of row and columnar partitions. You can use this feature to have archived data from previous months or years stored in columnar tables while active data is added to a heap table.
When performing operations on a partitioned table with a mix of row and columnar partitions, take note of the behaviors for operations that are supported on row tables but not columnar (e.g. tuple locks).
Creating additional databases
Hydra allows you to create additional databases with the CREATE DATABASE
command. New databases will have the default table type set to heap
. To change this, run:
Last updated