New Postgres superpowers in Hyperscale (Citus) with Citus 10

Published 05-08-2021 09:44 AM 5,808 Views
Microsoft

PostgreSQL is an excellent database for a wide range of workloads. Traditionally, the only problem with Postgres is that it is limited to a single machine. If you are using the Azure Database for PostgreSQL managed service, that limitation no longer applies to you because you can use the built-in Hyperscale (Citus) option—to transparently shard and scale out both transactional and analytical workloads. And Hyperscale (Citus) just keeps getting better and better.

 

The heart of Hyperscale (Citus) is the open source Citus extension which extends Postgres with distributed database superpowers. Every few months we release a new version of Citus. I’m excited to tell you that the latest release, Citus 10, is now available in preview on Hyperscale (Citus) and comes with spectacular new capabilities:

 

  • Columnar storage for Postgres: Compress your PostgreSQL and Hyperscale (Citus) tables to reduce storage cost and speed up your analytical queries!
  • Sharding on a single Citus node (Basic Tier): With Basic Tier, you can shard Postgres on a single node, so your application is “scale-out ready”. Also handy for trying out Hyperscale (Citus) at a much lower price point, starting at $0.27 USD/hour.[1]
  • Joins and foreign keys between local PostgreSQL tables and Citus tables: Mix and match PostgreSQL and Hyperscale (Citus) tables with foreign keys and joins.
  • Function to change the way your tables are distributed: Redistribute your tables in a single step using new alter table functions.
  • Much more: Better naming, improved SQL & DDL support, simplified operations.

 

These new Citus 10 capabilities change what Hyperscale (Citus) can do for you in some fundamental (and useful) ways.

 

With Citus 10, Hyperscale (Citus) is no longer just about sharding Postgres: you can use the new Citus columnar storage feature to compress large data sets. And Citus is no longer just about multi-node clusters: with Basic Tier in Hyperscale (Citus), you can now shard on a single node to be “scale-out-ready”. Finally, Hyperscale (Citus) is no longer just about transforming Postgres into a distributed database: you can now mix regular (local) Postgres tables and distributed tables in the same Postgres database.

 

In short, Hyperscale (Citus) in Azure Database for PostgreSQL now empowers you to run Postgres at any scale.

 

Let’s dive in!

 

One of our favourite Postgres memorabilia is the PostgreSQL 9.2 race car poster with the signatures of all the committers from the PGCon auction in 2013. Since Citus 9.2, our open source team has been creating a new racecar image for each new Citus open source release. With Citus 10 giving you columnar, single node (Basic tier), & so much more, the Postgres elephant can now go to any scale!One of our favourite Postgres memorabilia is the PostgreSQL 9.2 race car poster with the signatures of all the committers from the PGCon auction in 2013. Since Citus 9.2, our open source team has been creating a new racecar image for each new Citus open source release. With Citus 10 giving you columnar, single node (Basic tier), & so much more, the Postgres elephant can now go to any scale!

 

Columnar storage for PostgreSQL with Hyperscale (Citus)

 

The data sizes of some new Hyperscale (Citus) customers are truly gigantic, which meant we needed a way to lower storage cost and get more out of the hardware. That is why we implemented columnar storage for Citus. Citus Columnar can give you compression ratios of 3x-10x or more, and even greater I/O reductions. The new Citus columnar feature is available in:

 

  • Citus 10 open source: you can download the latest Citus packages here
  • Hyperscale (Citus) in Azure Database for PostgreSQL: at the time of writing, the Citus 10 features are in preview in Hyperscale (Citus). So if you want to try out the new Citus columnar feature, you’ll want to turn the preview features on in the portal when provisioning a new Hyperscale (Citus) server group. Of course, depending on when you read this blog post, these Citus 10 features might already be GA in Hyperscale (Citus).

 

The best part: you can use columnar in Hyperscale (Citus) with or without the Citus scale-out features! More details about columnar table storage can be found in our Hyperscale (Citus) docs.

 

Our Citus engineering team has a long history with columnar storage in PostgreSQL, as we originally developed the cstore_fdw extension which offered columnar storage via the foreign data wrapper (fdw) API. PostgreSQL 12 introduced “table access methods”, which allows extensions to define custom storage formats in a much more native way.

 

Citus makes columnar storage available in PostgreSQL via the table access method APIs, which means that you can now create Citus columnar tables by simply adding USING columnar when creating a table:

 

CREATE TABLE order_history (…) USING columnar;

 

If you provision a row-based (“heap”) table that you’d like to later convert to columnar, you can do that too, using the alter_table_set_access_method function:

 

-- compress a table using columnar storage (indexes are dropped)
SELECT alter_table_set_access_method('orders_2019', 'columnar');

 

When you use Citus columnar storage, you will typically see a 60-90% reduction in data size. In addition, Citus columnar will only read the columns used in the SQL query. This can give dramatic speed ups for I/O bound queries, and a big reduction in storage cost.

 

Compared to cstore_fdw, Citus columnar has a better compression ratio thanks to zstd compression. Citus columnar also supports rollback, streaming replication, archival, and pg_upgrade.

 

There are still a few limitations with Citus columnar to be aware of: Indexes and update/delete are not yet supported, and it is best to avoid single-row inserts, since compression only works well in batches. We plan to address these limitations in future Citus releases, but you can also avoid them using partitioning.

 

If you partition time series tables by time, you can use row-based storage for recent partitions to enable single-row, update/delete/upsert and indexes—while using columnar storage to archive data that is no longer changing. To make this easy, we also added a function to compress all your old partitions in one go:

 

-- compress all partitions older than 7 days
CALL alter_old_partitions_set_access_method('order_history', now() – interval '7 days', 'columnar');

 

This procedure commits after every partition to release locks as quickly as possible. You can use pg_cron to run this new alter function as a nightly compression job.

 

To learn more, check out Jeff Davis’ blog post: Citus 10 brings columnar compression to Postgres. Jeff also created a video demo, if you’re a more visual person this Citus columnar demo might be a good way to get acquainted.  

 

Starting with Basic Tier in Hyperscale (Citus)—to be “scale-out ready”

 

We often think of Hyperscale (Citus) as “worry-free Postgres”, because Citus takes away the one concern you may have when choosing Postgres as your database: reaching the limits of a single node. However, when you migrate a complex application from Postgres to Hyperscale (Citus), you may need to make some changes to your application to handle restrictions around unique- and foreign key-constraints and joins, since not every PostgreSQL feature has an efficient distributed implementation.

 

In Azure, the easiest way to scale your application on Postgres without ever facing the cost of migration (and be truly worry-free) is to use Hyperscale (Citus) from day one, when you first build your application. Applications built on Citus are always 100% compatible with regular PostgreSQL, so there is no risk of lock-in. The only downside of starting on Hyperscale (Citus) so far was the cost and complexity of running a distributed database cluster, but this changes in Citus 10. With Citus 10 and the new Basic tier in Hyperscale (Citus), you can now shard your Postgres tables on a single Citus node to make your database “scale-out-ready”.

 

To get started with Hyperscale (Citus) on a single node, this post about sharding Postgres with Basic tier is a good place to start. Be sure to enable preview features in the Azure portal when provisioning Azure Database for PostgreSQL—and then select the new “Basic Tier” feature that’s available in preview on Hyperscale (Citus). As of today, you can provision Basic tier for $0.27 USD/hour in US East 1. This means that you can try out Hyperscale (Citus) at a much lower price point: about ~8 hours of kicking the tires and you’ll only pay $2-3 USD.

 

Diagram 1: When provisioning the Hyperscale (Citus) deployment option in the Azure portal for Azure Database for PostgreSQL, you’ll now have two choices: Basic Tier and Standard Tier.Diagram 1: When provisioning the Hyperscale (Citus) deployment option in the Azure portal for Azure Database for PostgreSQL, you’ll now have two choices: Basic Tier and Standard Tier.

 

Once connected, you can create your first distributed table by running the following commands:

 

CREATE TABLE data (key text primary key, value jsonb not null);
SELECT create_distributed_table('data', 'key');

 

The create_distributed_table function will divide the table across 32 (hidden) shards that can be moved to new nodes when a single node is no longer sufficient.

 

You may experience some overhead from distributed query planning, but you will also see benefits from multi-shard queries being parallelized across cores. You can also make distributed, columnar tables to take advantage of both I/O and storage reduction and parallelism.

 

The biggest advantage of distributing Postgres tables with Basic tier in Hyperscale (Citus) is that your database will be ready to be scaled out using the Citus shard rebalancer.

 

Joins & foreign keys between PostgreSQL and Citus tables

 

With the new Basic Tier feature in Hyperscale (Citus) and the shard rebalancer, you can be ready to scale out by distributing your tables. However, distributing tables does involve certain trade-offs, such as extra network round trips when querying shards on worker nodes, and a few unsupported SQL features.

 

If you have a very large Postgres table and a data-intensive workload (e.g. the frequently-queried part of the table exceeds memory), then the performance gains from distributing the table over multiple nodes with Hyperscale (Citus) will vastly outweigh any downsides. However, if most of your other Postgres tables are small, then you might end up having to make additional changes without much additional benefit.

 

A simple solution would be to not distribute the smaller tables at all. In most Hyperscale (Citus) deployments, your application connects to a single coordinator node (which is usually sufficient), and the coordinator is a fully functional PostgreSQL node. That means you could organize your database as follows:

 

  • convert large tables into Citus distributed tables,
  • convert smaller tables that frequently JOIN with distributed tables into reference tables,
  • convert smaller tables that have foreign keys from distributed tables into reference tables,
  • keep all other tables as regular PostgreSQL tables local to the coordinator.

 

Diagram 2: Example of a data model where the really large table (clicks) is distributed. Because the Clicks table has a foreign key to Ads, we turn Ads into a reference table. Ads also has foreign keys to other tables, but we can keep those other tables (Campaigns, Publishers, Advertisers) as local tables on the coordinator.Diagram 2: Example of a data model where the really large table (clicks) is distributed. Because the Clicks table has a foreign key to Ads, we turn Ads into a reference table. Ads also has foreign keys to other tables, but we can keep those other tables (Campaigns, Publishers, Advertisers) as local tables on the coordinator.

 

That way, you can scale out CPU, memory, and I/O where you need it. And minimize application changes and other trade-offs where you don’t. To make this model work seamlessly, Citus 10 adds support for 2 important features:

 

  • foreign keys between local tables and reference tables
  • direct joins between local tables and distributed tables

 

With these new Citus 10 features in Hyperscale (Citus), you can mix and match PostgreSQL tables and Citus tables to get the best of both worlds without having to separate them in your data model.

 

Alter all the things!

 

When you distribute a Postgres table with Hyperscale (Citus), choosing your distribution column is an important step, since the distribution column (sometimes called the sharding key) determines which constraints you can create, how (fast) you can join tables, and more.

 

Citus 10 adds the alter_distributed_table function so you can change the distribution column, shard count, and co-location of a distributed table. This blog post walks through how when and why to use alter_distributed_table with Hyperscale (Citus).

 

-- change the distribution column to customer_id
SELECT alter_distributed_table('orders',
                               distribution_column := 'customer_id'); 

-- change the shard count to 120
SELECT alter_distributed_table('orders',
                               shard_count := 120);

-- Co-locate with another table
SELECT alter_distributed_table('orders',
                               distribution_column := 'product_id', 
                               colocate_with := 'products');

 

Internally, alter_distributed_table reshuffles the data between the worker nodes, which means it is fast and works well on very large tables. We expect this makes it much easier to experiment with distributing your tables without having to reload your data.

 

You can also use the alter_distributed_table function in production (it’s fully transactional!), but you do need to (1) make sure that you have enough disk space to store the table several times, and (2) make sure that your application can tolerate blocking all writes to the table for a while.

 

Many other features in Citus 10—now available in preview in Hyperscale (Citus)

 

And there’s more!

  • DDL support
    More DDL commands work seamlessly on distributed Citus tables, including CREATE STATISTICS, ALTER TABLE .. SET LOGGED, and ALTER SCHEMA .. RENAME.

  • SQL support
    Correlated subqueries can now be used in the SELECT part of the query, as long as the distributed tables are joined by their distribution column.

  • New views to see the state of your cluster: citus_tables and citus_shards
    citus_tables view shows Citus tables and their distribution column, total size, and access method. The citus_shards view shows the names, locations, and sizes of individual shards.

 

Two easy ways to start playing with Citus 10

 

If you are as excited as we are and want to play with these new Citus 10 features, doing so is now easier than ever.

 

  1. The Basic Tier in Hyperscale (Citus) makes it very cheap to get started with a managed Citus node in our Azure Database for PostgreSQL managed service. (There’s a Basic tier Quickstart in our Azure docs, too.) 

  2. And you can also run Citus open source on your laptop as a single Docker container! Not only is the single docker run command an easy way to try out Citus—it gives you functional parity between your local dev machine and using Citus in the cloud.

 

# run PostgreSQL with Citus on port 5500
docker run -d --name citus -p 5500:5432 -e POSTGRES_PASSWORD=mypassword citusdata/citus

# connect
psql -U postgres -d postgres -h localhost -p 5500

 

You can also check out our lovely new Getting started with Citus page for more resources on how to get started—my teammates have curated some good learning tools there, whether your preferred learning mode is reading, watching, or doing.

 

More deep-dive blog posts about new Citus 10 capabilities

 

And since the Citus 10 open source release rolled out, we’ve also published a bunch of deep-dive blog posts (plus a demo!) about the spectacular new capabilities in Citus 10:

 

 

Finally, a big thank you to all of you who use Hyperscale (Citus) to scale out Postgres and who have taken the time to give feedback and be part of our journey. If you’ve filed issues on GitHub, submitted PRs, talked to our @citusdata or @AzureDBPostgres team on Twitter, signed up for our monthly Citus technical newsletter, or joined our Citus Public community Q&A... well, thank you. And please, keep the feedback coming. You can always reach our product team via the Ask Azure DB for PostgreSQL email address too.

We can’t wait to see what you do with the new Citus 10 features in Hyperscale (Citus)!


Footnotes

  1. As of the time of publication, in the East US region on Azure, the cost of a Hyperscale (Citus) Basic tier with 2 vCores, 8 GiB total memory, and 128 GiB of storage on the coordinator node is $0.27/hour or ~$200/month
%3CLINGO-SUB%20id%3D%22lingo-sub-2335404%22%20slang%3D%22en-US%22%3ENew%20Postgres%20superpowers%20in%20Hyperscale%20(Citus)%20with%20Citus%2010%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2335404%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EPostgreSQL%20is%20an%20excellent%20database%20for%20a%20wide%20range%20of%20workloads.%20Traditionally%2C%20the%20only%20problem%20with%20Postgres%20is%20that%20it%20is%20limited%20to%20a%20single%20machine.%20If%20you%20are%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fpostgresql%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Database%20for%20PostgreSQL%3C%2FA%3E%20managed%20service%2C%20that%20limitation%20no%20longer%20applies%20to%20you%20because%20you%20can%20use%20the%20built-in%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fpostgresql%2Fhyperscale%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHyperscale%20(Citus)%3C%2FA%3E%20option%E2%80%94to%20transparently%20shard%20and%20scale%20out%20both%20transactional%20and%20analytical%20workloads.%20And%20Hyperscale%20(Citus)%20just%20keeps%20getting%20better%20and%20better.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20heart%20of%20Hyperscale%20(Citus)%20is%20the%20open%20source%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fcitusdata%2Fcitus%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECitus%20extension%3C%2FA%3E%20which%20extends%20Postgres%20with%20distributed%20database%20superpowers.%20Every%20few%20months%20we%20release%20a%20new%20version%20of%20Citus.%20I%E2%80%99m%20excited%20to%20tell%20you%20that%20%3CA%20href%3D%22https%3A%2F%2Fwww.citusdata.com%2Fblog%2F2021%2F03%2F05%2Fcitus-10-release-open-source-rebalancer-and-columnar-for-postgres%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ethe%20latest%20release%2C%20Citus%2010%3C%2FA%3E%2C%20is%20now%20available%20in%20preview%20on%20Hyperscale%20(Citus)%20and%20comes%20with%20spectacular%20new%20capabilities%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EColumnar%20storage%20for%20Postgres%3C%2FSTRONG%3E%3A%20Compress%20your%20PostgreSQL%20and%20Hyperscale%20(Citus)%20tables%20to%20reduce%20storage%20cost%20and%20speed%20up%20your%20analytical%20queries!%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ESharding%20on%20a%20single%20Citus%20node%20(Basic%20Tier)%3C%2FSTRONG%3E%3A%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-database-for-postgresql%2Fsharding-postgres-with-basic-tier-in-hyperscale-citus-how-why%2Fba-p%2F2275672%22%20target%3D%22_blank%22%3EWith%20Basic%20Tier%3C%2FA%3E%2C%20you%20can%20shard%20Postgres%20on%20a%20single%20node%2C%20so%20your%20application%20is%20%E2%80%9Cscale-out%20ready%E2%80%9D.%20Also%20handy%20for%20trying%20out%20Hyperscale%20(Citus)%20at%20a%20much%20lower%20price%20point%2C%20starting%20at%20%240.27%20USD%2Fhour.%3CSUP%3E%3CA%20href%3D%22%23ftn1%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20name%3D%22ftnref1%22%3E%5B1%5D%3C%2FA%3E%3C%2FSUP%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EJoins%20and%20foreign%20keys%20between%20local%20PostgreSQL%20tables%20and%20Citus%20tables%3C%2FSTRONG%3E%3A%20Mix%20and%20match%20PostgreSQL%20and%20Hyperscale%20(Citus)%20tables%20with%20foreign%20keys%20and%20joins.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EFunction%3C%2FSTRONG%3E%3CSTRONG%3E%20to%20change%20the%20way%20your%20tables%20are%20distributed%3C%2FSTRONG%3E%3A%20Redistribute%20your%20tables%20in%20a%20single%20step%20using%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-database-for-postgresql%2Fcitus-tips-for-postgres-how-to-alter-distribution-key-shard%2Fba-p%2F2311470%22%20target%3D%22_blank%22%3Enew%20alter%20table%20functions%3C%2FA%3E.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EMuch%20more%3C%2FSTRONG%3E%3A%20Better%20naming%2C%20improved%20SQL%20%26amp%3B%20DDL%20support%2C%20simplified%20operations.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThese%20new%20Citus%2010%20capabilities%20change%20what%20Hyperscale%20(Citus)%20can%20do%20for%20you%20in%20some%20fundamental%20(and%20useful)%20ways.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20Citus%2010%2C%20Hyperscale%20(Citus)%20is%20no%20longer%20just%20about%20sharding%20Postgres%3A%20you%20can%20use%20the%20new%20Citus%20columnar%20storage%20feature%20to%20compress%20large%20data%20sets.%20And%20Citus%20is%20no%20longer%20just%20about%20multi-node%20clusters%3A%20with%20Basic%20Tier%20in%20Hyperscale%20(Citus)%2C%20you%20can%20now%20shard%20on%20a%20single%20node%20to%20be%20%E2%80%9Cscale-out-ready%E2%80%9D.%20Finally%2C%20Hyperscale%20(Citus)%20is%20no%20longer%20just%20about%20transforming%20Postgres%20into%20a%20distributed%20database%3A%20you%20can%20now%20mix%20regular%20(local)%20Postgres%20tables%20and%20distributed%20tables%20in%20the%20same%20Postgres%20database.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20short%2C%20Hyperscale%20(Citus)%20in%20Azure%20Database%20for%20PostgreSQL%20now%20empowers%20you%20to%20run%20Postgres%20at%20any%20scale.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20dive%20in!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Citus10-elephant-release-graphic-drone-against-Azure-blue-with-cloud-1920x1080.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279258i38A2550677C31B90%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Citus10-elephant-release-graphic-drone-against-Azure-blue-with-cloud-1920x1080.jpg%22%20alt%3D%22One%20of%20our%20favourite%20Postgres%20memorabilia%20is%20the%20PostgreSQL%209.2%20race%20car%20poster%20with%20the%20signatures%20of%20all%20the%20committers%20from%20the%20PGCon%20auction%20in%202013.%20Since%20Citus%209.2%2C%20our%20open%20source%20team%20has%20been%20creating%20a%20new%20racecar%20image%20for%20each%20new%20Citus%20open%20source%20release.%20With%20Citus%2010%20giving%20you%20columnar%2C%20single%20node%20(Basic%20tier)%2C%20%26amp%3B%20so%20much%20more%2C%20the%20Postgres%20elephant%20can%20now%20go%20to%20any%20scale!%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EOne%20of%20our%20favourite%20Postgres%20memorabilia%20is%20the%20PostgreSQL%209.2%20race%20car%20poster%20with%20the%20signatures%20of%20all%20the%20committers%20from%20the%20PGCon%20auction%20in%202013.%20Since%20Citus%209.2%2C%20our%20open%20source%20team%20has%20been%20creating%20a%20new%20racecar%20image%20for%20each%20new%20Citus%20open%20source%20release.%20With%20Citus%2010%20giving%20you%20columnar%2C%20single%20node%20(Basic%20tier)%2C%20%26amp%3B%20so%20much%20more%2C%20the%20Postgres%20elephant%20can%20now%20go%20to%20any%20scale!%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--468721453%22%20id%3D%22toc-hId--468781035%22%3EColumnar%20storage%20for%20PostgreSQL%20with%20Hyperscale%20(Citus)%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20data%20sizes%20of%20some%20new%20Hyperscale%20(Citus)%20customers%20are%20truly%20gigantic%2C%20which%20meant%20we%20needed%20a%20way%20to%20lower%20storage%20cost%20and%20get%20more%20out%20of%20the%20hardware.%20That%20is%20why%20we%20implemented%20columnar%20storage%20for%20Citus.%20Citus%20Columnar%20can%20give%20you%20compression%20ratios%20of%203x-10x%20or%20more%2C%20and%20even%20greater%20I%2FO%20reductions.%20The%20new%20Citus%20columnar%20feature%20is%20available%20in%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ECitus%2010%20open%20source%3C%2FSTRONG%3E%3A%20you%20can%20%3CA%20href%3D%22https%3A%2F%2Fwww.citusdata.com%2Fdownload%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Edownload%20the%20latest%20Citus%3C%2FA%3E%20packages%20here%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EHyperscale%20(Citus)%20in%20Azure%20Database%20for%20PostgreSQL%3C%2FSTRONG%3E%3A%20at%20the%20time%20of%20writing%2C%20the%20Citus%2010%20features%20are%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fpostgresql%2Fhyperscale-preview-features%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ein%20preview%20in%20Hyperscale%20(Citus)%3C%2FA%3E.%20So%20if%20you%20want%20to%20try%20out%20the%20new%20Citus%20columnar%20feature%2C%20you%E2%80%99ll%20want%20to%20turn%20the%20preview%20features%20on%20in%20the%20portal%20when%20provisioning%20a%20new%20Hyperscale%20(Citus)%20server%20group.%20Of%20course%2C%20depending%20on%20when%20you%20read%20this%20blog%20post%2C%20these%20Citus%2010%20features%20might%20already%20be%20GA%20in%20Hyperscale%20(Citus).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20best%20part%3A%20you%20can%20use%20columnar%20in%20Hyperscale%20(Citus)%20with%20or%20without%20the%20Citus%20scale-out%20features!%20More%20details%20about%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fpostgresql%2Fconcepts-hyperscale-columnar%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecolumnar%20table%20storage%3C%2FA%3E%20can%20be%20found%20in%20our%20Hyperscale%20(Citus)%20docs.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOur%20Citus%20engineering%20team%20has%20a%20long%20history%20with%20columnar%20storage%20in%20PostgreSQL%2C%20as%20we%20originally%20developed%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fcitusdata%2Fcstore_fdw%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecstore_fdw%20extension%3C%2FA%3E%20which%20offered%20columnar%20storage%20via%20the%20foreign%20data%20wrapper%20(fdw)%20API.%20PostgreSQL%2012%20introduced%20%E2%80%9Ctable%20access%20methods%E2%80%9D%2C%20which%20allows%20extensions%20to%20define%20custom%20storage%20formats%20in%20a%20much%20more%20native%20way.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECitus%20makes%20columnar%20storage%20available%20in%20PostgreSQL%20via%20the%20table%20access%20method%20APIs%2C%20which%20means%20that%20you%20can%20now%20create%20Citus%20columnar%20tables%20by%20simply%20adding%3CCODE%20style%3D%22color%3A%20black%3B%22%3EUSING%20columnar%3C%2FCODE%3Ewhen%20creating%20a%20table%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3ECREATE%20TABLE%20order_history%20(%E2%80%A6)%20USING%20columnar%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20provision%20a%20row-based%20(%E2%80%9Cheap%E2%80%9D)%20table%20that%20you%E2%80%99d%20like%20to%20later%20convert%20to%20columnar%2C%20you%20can%20do%20that%20too%2C%20using%20the%3CCODE%20style%3D%22color%3A%20black%3B%22%3Ealter_table_set_access_method%3C%2FCODE%3Efunction%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3E--%20compress%20a%20table%20using%20columnar%20storage%20(indexes%20are%20dropped)%0ASELECT%20alter_table_set_access_method('orders_2019'%2C%20'columnar')%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20you%20use%20Citus%20columnar%20storage%2C%20you%20will%20typically%20see%20a%2060-90%25%20reduction%20in%20data%20size.%20In%20addition%2C%20Citus%20columnar%20will%20only%20read%20the%20columns%20used%20in%20the%20SQL%20query.%20This%20can%20give%20dramatic%20speed%20ups%20for%20I%2FO%20bound%20queries%2C%20and%20a%20big%20reduction%20in%20storage%20cost.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECompared%20to%3CCODE%20style%3D%22color%3A%20black%3B%22%3Ecstore_fdw%3C%2FCODE%3E%2C%20Citus%20columnar%20has%20a%20better%20compression%20ratio%20thanks%20to%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Ffacebook%2Fzstd%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ezstd%20compression%3C%2FA%3E.%20Citus%20columnar%20also%20supports%20rollback%2C%20streaming%20replication%2C%20archival%2C%20and%20pg_upgrade.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20still%20a%20few%20limitations%20with%20Citus%20columnar%20to%20be%20aware%20of%3A%20Indexes%20and%20update%2Fdelete%20are%20not%20yet%20supported%2C%20and%20it%20is%20best%20to%20avoid%20single-row%20inserts%2C%20since%20compression%20only%20works%20well%20in%20batches.%20We%20plan%20to%20address%20these%20limitations%20in%20future%20Citus%20releases%2C%20but%20you%20can%20also%20avoid%20them%20using%20partitioning.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20%3CA%20href%3D%22https%3A%2F%2Fdocs.citusdata.com%2Fen%2Fstable%2Fuse_cases%2Ftimeseries.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Epartition%20time%20series%20tables%20by%20time%3C%2FA%3E%2C%20you%20can%20use%20row-based%20storage%20for%20recent%20partitions%20to%20enable%20single-row%2C%20update%2Fdelete%2Fupsert%20and%20indexes%E2%80%94while%20using%20columnar%20storage%20to%20archive%20data%20that%20is%20no%20longer%20changing.%20To%20make%20this%20easy%2C%20we%20also%20added%20a%20function%20to%20compress%20all%20your%20old%20partitions%20in%20one%20go%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3E--%20compress%20all%20partitions%20older%20than%207%20days%0ACALL%20alter_old_partitions_set_access_method('order_history'%2C%20now()%20%E2%80%93%20interval%20'7%20days'%2C%20'columnar')%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20procedure%20commits%20after%20every%20partition%20to%20release%20locks%20as%20quickly%20as%20possible.%20You%20can%20use%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fcitusdata%2Fpg_cron%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Epg_cron%3C%2FA%3E%20to%20run%20this%20new%20alter%20function%20as%20a%20nightly%20compression%20job.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20learn%20more%2C%20check%20out%20Jeff%20Davis%E2%80%99%20blog%20post%3A%20%3CA%20href%3D%22https%3A%2F%2Fwww.citusdata.com%2Fblog%2F2021%2F03%2F06%2Fcitus-10-columnar-compression-for-postgres%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ECitus%2010%20brings%20columnar%20compression%20to%20Postgres%3C%2FA%3E.%20Jeff%20also%20created%20a%20video%20demo%2C%20if%20you%E2%80%99re%20a%20more%20visual%20person%20this%20%3CA%20href%3D%22https%3A%2F%2Fyoutu.be%2FSS7jcq9fTnw%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ECitus%20columnar%20demo%3C%2FA%3E%20might%20be%20a%20good%20way%20to%20get%20acquainted.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-2018791380%22%20id%3D%22toc-hId-2018731798%22%3EStarting%20with%20Basic%20Tier%20in%20Hyperscale%20(Citus)%E2%80%94to%20be%20%E2%80%9Cscale-out%20ready%E2%80%9D%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20often%20think%20of%20Hyperscale%20(Citus)%20as%20%E2%80%9Cworry-free%20Postgres%E2%80%9D%2C%20because%20Citus%20takes%20away%20the%20one%20concern%20you%20may%20have%20when%20choosing%20Postgres%20as%20your%20database%3A%20reaching%20the%20limits%20of%20a%20single%20node.%20However%2C%20when%20you%20migrate%20a%20complex%20application%20from%20Postgres%20to%20Hyperscale%20(Citus)%2C%20you%20may%20need%20to%20make%20some%20changes%20to%20your%20application%20to%20handle%20restrictions%20around%20unique-%20and%20foreign%20key-constraints%20and%20joins%2C%20since%20not%20every%20PostgreSQL%20feature%20has%20an%20efficient%20distributed%20implementation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20Azure%2C%20the%20easiest%20way%20to%20scale%20your%20application%20on%20Postgres%20without%20ever%20facing%20the%20cost%20of%20migration%20(and%20be%20truly%20worry-free)%20is%20to%20use%20Hyperscale%20(Citus)%20from%20day%20one%2C%20when%20you%20first%20build%20your%20application.%20Applications%20built%20on%20Citus%20are%20always%20100%25%20compatible%20with%20regular%20PostgreSQL%2C%20so%20there%20is%20no%20risk%20of%20lock-in.%20The%20only%20downside%20of%20starting%20on%20Hyperscale%20(Citus)%20so%20far%20was%20the%20cost%20and%20complexity%20of%20running%20a%20distributed%20database%20cluster%2C%20but%20this%20changes%20in%20Citus%2010.%20With%20Citus%2010%20and%20the%20new%20Basic%20tier%20in%20Hyperscale%20(Citus)%2C%20you%20can%20now%20shard%20your%20Postgres%20tables%20on%20a%20single%20Citus%20node%20to%20make%20your%20database%20%E2%80%9Cscale-out-ready%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20get%20started%20with%20Hyperscale%20(Citus)%20on%20a%20single%20node%2C%20this%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-database-for-postgresql%2Fsharding-postgres-with-basic-tier-in-hyperscale-citus-how-why%2Fba-p%2F2275672%22%20target%3D%22_blank%22%3Epost%20about%20sharding%20Postgres%20with%20Basic%20tier%3C%2FA%3E%20is%20a%20good%20place%20to%20start.%20Be%20sure%20to%20enable%20preview%20features%20in%20the%20Azure%20portal%20when%20provisioning%20Azure%20Database%20for%20PostgreSQL%E2%80%94and%20then%20select%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fpostgresql%2Fconcepts-hyperscale-tiers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Enew%20%E2%80%9CBasic%20Tier%E2%80%9D%20feature%3C%2FA%3E%20that%E2%80%99s%20available%20in%20preview%20on%20Hyperscale%20(Citus).%20As%20of%20today%2C%20you%20can%20provision%20Basic%20tier%20for%20%240.27%20USD%2Fhour%20in%20US%20East%201.%20This%20means%20that%20you%20can%20try%20out%20Hyperscale%20(Citus)%20at%20a%20much%20lower%20price%20point%3A%20about%20~8%20hours%20of%20kicking%20the%20tires%20and%20you%E2%80%99ll%20only%20pay%20%242-3%20USD.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22diagram-1-screenshot-azure-portal-compute-storage-basic-tier-for-Citus10-blog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279259i65FBA0F95C64F61A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22diagram-1-screenshot-azure-portal-compute-storage-basic-tier-for-Citus10-blog.png%22%20alt%3D%22Diagram%201%3A%20When%20provisioning%20the%20Hyperscale%20(Citus)%20deployment%20option%20in%20the%20Azure%20portal%20for%20Azure%20Database%20for%20PostgreSQL%2C%20you%E2%80%99ll%20now%20have%20two%20choices%3A%20Basic%20Tier%20and%20Standard%20Tier.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EDiagram%201%3A%20When%20provisioning%20the%20Hyperscale%20(Citus)%20deployment%20option%20in%20the%20Azure%20portal%20for%20Azure%20Database%20for%20PostgreSQL%2C%20you%E2%80%99ll%20now%20have%20two%20choices%3A%20Basic%20Tier%20and%20Standard%20Tier.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20connected%2C%20you%20can%20create%20your%20first%20distributed%20table%20by%20running%20the%20following%20commands%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3ECREATE%20TABLE%20data%20(key%20text%20primary%20key%2C%20value%20jsonb%20not%20null)%3B%0ASELECT%20create_distributed_table('data'%2C%20'key')%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%3CCODE%20style%3D%22color%3A%20black%3B%22%3Ecreate_distributed_table%3C%2FCODE%3Efunction%20will%20divide%20the%20table%20across%2032%20(hidden)%20shards%20that%20can%20be%20moved%20to%20new%20nodes%20when%20a%20single%20node%20is%20no%20longer%20sufficient.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20may%20experience%20some%20overhead%20from%20distributed%20query%20planning%2C%20but%20you%20will%20also%20see%20benefits%20from%20multi-shard%20queries%20being%20parallelized%20across%20cores.%20You%20can%20also%20make%20distributed%2C%20columnar%20tables%20to%20take%20advantage%20of%20both%20I%2FO%20and%20storage%20reduction%20and%20parallelism.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20biggest%20advantage%20of%20distributing%20Postgres%20tables%20with%20Basic%20tier%20in%20Hyperscale%20(Citus)%20is%20that%20your%20database%20will%20be%20ready%20to%20be%20scaled%20out%20using%20the%20Citus%20shard%20rebalancer.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-211336917%22%20id%3D%22toc-hId-211277335%22%3EJoins%20%26amp%3B%20foreign%20keys%20between%20PostgreSQL%20and%20Citus%20tables%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20the%20new%20Basic%20Tier%20feature%20in%20Hyperscale%20(Citus)%20and%20the%20shard%20rebalancer%2C%20you%20can%20be%20ready%20to%20scale%20out%20by%20distributing%20your%20tables.%20However%2C%20distributing%20tables%20does%20involve%20certain%20trade-offs%2C%20such%20as%20extra%20network%20round%20trips%20when%20querying%20shards%20on%20worker%20nodes%2C%20and%20a%20few%20%3CA%20href%3D%22https%3A%2F%2Fdocs.citusdata.com%2Fen%2Fstable%2Fdevelop%2Freference_workarounds.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Eunsupported%20SQL%20features%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20a%20very%20large%20Postgres%20table%20and%20a%20data-intensive%20workload%20(e.g.%20the%20frequently-queried%20part%20of%20the%20table%20exceeds%20memory)%2C%20then%20the%20performance%20gains%20from%20distributing%20the%20table%20over%20multiple%20nodes%20with%20Hyperscale%20(Citus)%20will%20vastly%20outweigh%20any%20downsides.%20However%2C%20if%20most%20of%20your%20other%20Postgres%20tables%20are%20small%2C%20then%20you%20might%20end%20up%20having%20to%20make%20additional%20changes%20without%20much%20additional%20benefit.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20simple%20solution%20would%20be%20to%20%3CEM%3Enot%3C%2FEM%3E%20distribute%20the%20smaller%20tables%20at%20all.%20In%20most%20Hyperscale%20(Citus)%20deployments%2C%20your%20application%20connects%20to%20a%20single%20coordinator%20node%20(which%20is%20usually%20sufficient)%2C%20and%20the%20coordinator%20is%20a%20fully%20functional%20PostgreSQL%20node.%20That%20means%20you%20could%20organize%20your%20database%20as%20follows%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Econvert%20large%20tables%20into%20Citus%20distributed%20tables%2C%3C%2FLI%3E%0A%3CLI%3Econvert%20smaller%20tables%20that%20frequently%20JOIN%20with%20distributed%20tables%20into%20reference%20tables%2C%3C%2FLI%3E%0A%3CLI%3Econvert%20smaller%20tables%20that%20have%20foreign%20keys%20from%20distributed%20tables%20into%20reference%20tables%2C%3C%2FLI%3E%0A%3CLI%3Ekeep%20all%20other%20tables%20as%20regular%20PostgreSQL%20tables%20local%20to%20the%20coordinator.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22diagram2-distributed-data-model-with-clicks-ads-publishers-campaigns.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279260i962A3727973ED18B%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22diagram2-distributed-data-model-with-clicks-ads-publishers-campaigns.png%22%20alt%3D%22Diagram%202%3A%20Example%20of%20a%20data%20model%20where%20the%20really%20large%20table%20(clicks)%20is%20distributed.%20Because%20the%20Clicks%20table%20has%20a%20foreign%20key%20to%20Ads%2C%20we%20turn%20Ads%20into%20a%20reference%20table.%20Ads%20also%20has%20foreign%20keys%20to%20other%20tables%2C%20but%20we%20can%20keep%20those%20other%20tables%20(Campaigns%2C%20Publishers%2C%20Advertisers)%20as%20local%20tables%20on%20the%20coordinator.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EDiagram%202%3A%20Example%20of%20a%20data%20model%20where%20the%20really%20large%20table%20(clicks)%20is%20distributed.%20Because%20the%20Clicks%20table%20has%20a%20foreign%20key%20to%20Ads%2C%20we%20turn%20Ads%20into%20a%20reference%20table.%20Ads%20also%20has%20foreign%20keys%20to%20other%20tables%2C%20but%20we%20can%20keep%20those%20other%20tables%20(Campaigns%2C%20Publishers%2C%20Advertisers)%20as%20local%20tables%20on%20the%20coordinator.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat%20way%2C%20you%20can%20scale%20out%20CPU%2C%20memory%2C%20and%20I%2FO%20where%20you%20need%20it.%20And%20minimize%20application%20changes%20and%20other%20trade-offs%20where%20you%20don%E2%80%99t.%20To%20make%20this%20model%20work%20seamlessly%2C%20Citus%2010%20adds%20support%20for%202%20important%20features%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Eforeign%20keys%20between%20local%20tables%20and%20reference%20tables%3C%2FLI%3E%0A%3CLI%3Edirect%20joins%20between%20local%20tables%20and%20distributed%20tables%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20these%20new%20Citus%2010%20features%20in%20Hyperscale%20(Citus)%2C%20you%20can%20mix%20and%20match%20PostgreSQL%20tables%20and%20Citus%20tables%20to%20get%20the%20best%20of%20both%20worlds%20without%20having%20to%20separate%20them%20in%20your%20data%20model.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1596117546%22%20id%3D%22toc-hId--1596177128%22%3EAlter%20all%20the%20things!%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20you%20distribute%20a%20Postgres%20table%20with%20Hyperscale%20(Citus)%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fpostgresql%2Fconcepts-hyperscale-choose-distribution-column%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Echoosing%20your%20distribution%20column%3C%2FA%3E%20is%20an%20important%20step%2C%20since%20the%20distribution%20column%20(sometimes%20called%20the%20sharding%20key)%20determines%20which%20constraints%20you%20can%20create%2C%20how%20(fast)%20you%20can%20join%20tables%2C%20and%20more.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECitus%2010%20adds%20the%3CCODE%20style%3D%22color%3A%20black%3B%22%3Ealter_distributed_table%3C%2FCODE%3Efunction%20so%20you%20can%20change%20the%20distribution%20column%2C%20shard%20count%2C%20and%20co-location%20of%20a%20distributed%20table.%20This%20blog%20post%20walks%20through%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-database-for-postgresql%2Fcitus-tips-for-postgres-how-to-alter-distribution-key-shard%2Fba-p%2F2311470%22%20target%3D%22_blank%22%3Ehow%20when%20and%20why%20to%20use%20alter_distributed_table%3C%2FA%3E%20with%20Hyperscale%20(Citus).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3E--%20change%20the%20distribution%20column%20to%20customer_id%0ASELECT%20alter_distributed_table('orders'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20distribution_column%20%3A%3D%20'customer_id')%3B%20%0A%0A--%20change%20the%20shard%20count%20to%20120%0ASELECT%20alter_distributed_table('orders'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20shard_count%20%3A%3D%20120)%3B%0A%0A--%20Co-locate%20with%20another%20table%0ASELECT%20alter_distributed_table('orders'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20distribution_column%20%3A%3D%20'product_id'%2C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20colocate_with%20%3A%3D%20'products')%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EInternally%2C%3CCODE%20style%3D%22color%3A%20black%3B%22%3Ealter_distributed_table%3C%2FCODE%3Ereshuffles%20the%20data%20between%20the%20worker%20nodes%2C%20which%20means%20it%20is%20fast%20and%20works%20well%20on%20very%20large%20tables.%20We%20expect%20this%20makes%20it%20much%20easier%20to%20experiment%20with%20distributing%20your%20tables%20without%20having%20to%20reload%20your%20data.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20use%20the%3CCODE%20style%3D%22color%3A%20black%3B%22%3Ealter_distributed_table%3C%2FCODE%3Efunction%20in%20production%20(it%E2%80%99s%20fully%20transactional!)%2C%20but%20you%20do%20need%20to%20(1)%20make%20sure%20that%20you%20have%20enough%20disk%20space%20to%20store%20the%20table%20several%20times%2C%20and%20(2)%20make%20sure%20that%20your%20application%20can%20tolerate%20blocking%20all%20writes%20to%20the%20table%20for%20a%20while.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-891395287%22%20id%3D%22toc-hId-891335705%22%3EMany%20other%20features%20in%20Citus%2010%E2%80%94now%20available%20in%20preview%20in%20Hyperscale%20(Citus)%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20there%E2%80%99s%20more!%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EDDL%20support%3C%2FSTRONG%3E%3CBR%20%2F%3EMore%20DDL%20commands%20work%20seamlessly%20on%20distributed%20Citus%20tables%2C%20including%20CREATE%20STATISTICS%2C%20ALTER%20TABLE%20..%20SET%20LOGGED%2C%20and%20ALTER%20SCHEMA%20..%20RENAME.%3CSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ESQL%20support%3C%2FSTRONG%3E%3CBR%20%2F%3ECorrelated%20subqueries%20can%20now%20be%20used%20in%20the%20SELECT%20part%20of%20the%20query%2C%20as%20long%20as%20the%20distributed%20tables%20are%20joined%20by%20their%20distribution%20column.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ENew%20views%3C%2FSTRONG%3E%3CSTRONG%3E%20to%20see%20the%20state%20of%20your%20cluster%3A%20citus_tables%20and%20citus_shards%3CBR%20%2F%3E%3C%2FSTRONG%3E%3CCODE%20style%3D%22color%3A%20black%3B%22%3Ecitus_tables%3C%2FCODE%3Eview%20shows%20Citus%20tables%20and%20their%20distribution%20column%2C%20total%20size%2C%20and%20access%20method.%20The%3CCODE%20style%3D%22color%3A%20black%3B%22%3Ecitus_shards%3C%2FCODE%3Eview%20shows%20the%20names%2C%20locations%2C%20and%20sizes%20of%20individual%20shards.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--916059176%22%20id%3D%22toc-hId--916118758%22%3ETwo%20easy%20ways%20to%20start%20playing%20with%20Citus%2010%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20as%20excited%20as%20we%20are%20and%20want%20to%20play%20with%20these%20new%20Citus%2010%20features%2C%20doing%20so%20is%20now%20easier%20than%20ever.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EThe%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-database-for-postgresql%2Fsharding-postgres-with-basic-tier-in-hyperscale-citus-how-why%2Fba-p%2F2275672%22%20target%3D%22_blank%22%3EBasic%20Tier%20in%20Hyperscale%20(Citus)%3C%2FA%3E%20makes%20it%20very%20cheap%20to%20get%20started%20with%20a%20managed%20Citus%20node%20in%20our%20Azure%20Database%20for%20PostgreSQL%20managed%20service.%20(There%E2%80%99s%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fpostgresql%2Fquickstart-create-hyperscale-basic-tier%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EBasic%20tier%20Quickstart%3C%2FA%3E%20in%20our%20Azure%20docs%2C%20too.)%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3EAnd%20you%20can%20also%20run%20%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fwww.citusdata.com%2Fdownload%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ECitus%20open%20source%3C%2FA%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%20on%20your%20laptop%20as%20a%20single%20Docker%20container!%20Not%20only%20is%20the%20single%20docker%20run%20command%20an%20easy%20way%20to%20try%20out%20Citus%E2%80%94it%20gives%20you%20functional%20parity%20between%20your%20local%20dev%20machine%20and%20using%20Citus%20in%20the%20cloud.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%23%20run%20PostgreSQL%20with%20Citus%20on%20port%205500%0Adocker%20run%20-d%20--name%20citus%20-p%205500%3A5432%20-e%20POSTGRES_PASSWORD%3Dmypassword%20citusdata%2Fcitus%0A%0A%23%20connect%0Apsql%20-U%20postgres%20-d%20postgres%20-h%20localhost%20-p%205500%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20check%20out%20our%20lovely%20new%20%3CA%20href%3D%22https%3A%2F%2Fwww.citusdata.com%2Fgetting-started%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EGetting%20started%20with%20Citus%3C%2FA%3E%20page%20for%20more%20resources%20on%20how%20to%20get%20started%E2%80%94my%20teammates%20have%20curated%20some%20good%20learning%20tools%20there%2C%20whether%20your%20preferred%20learning%20mode%20is%20reading%2C%20watching%2C%20or%20doing.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1571453657%22%20id%3D%22toc-hId-1571394075%22%3EMore%20deep-dive%20blog%20posts%20about%20new%20Citus%2010%20capabilities%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20since%20the%20Citus%2010%20open%20source%20release%20rolled%20out%2C%20we%E2%80%99ve%20also%20published%20a%20bunch%20of%20deep-dive%20blog%20posts%20(plus%20a%20demo!)%20about%20the%20spectacular%20new%20capabilities%20in%20Citus%2010%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fwww.citusdata.com%2Fblog%2F2021%2F03%2F06%2Fcitus-10-columnar-compression-for-postgres%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ECitus%2010%20brings%20columnar%20compression%20to%20Postgres%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fyoutu.be%2FSS7jcq9fTnw%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EVideo%20demo%20of%20Citus%20Columnar%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fwww.citusdata.com%2Fblog%2F2021%2F03%2F13%2Fscaling-out-postgres-with-citus-open-source-shard-rebalancer%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EOpen%20sourcing%20of%20the%20Citus%20shard%20rebalancer%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-database-for-postgresql%2Fsharding-postgres-with-basic-tier-in-hyperscale-citus-how-why%2Fba-p%2F2275672%22%20target%3D%22_blank%22%3ESharding%20Postgres%20with%20Basic%20tier%20in%20Hyperscale%20(Citus)%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-database-for-postgresql%2Fcitus-tips-for-postgres-how-to-alter-distribution-key-shard%2Fba-p%2F2311470%22%20target%3D%22_blank%22%3ECitus%20Tips%20for%20Postgres%2C%20how%20to%20alter%20distribution%20key%2C%20shard%20count%2C%20%26amp%3B%20more%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFinally%2C%20a%20big%20thank%20you%20to%20all%20of%20you%20who%20use%20Hyperscale%20(Citus)%20to%20scale%20out%20Postgres%20and%20who%20have%20taken%20the%20time%20to%20give%20feedback%20and%20be%20part%20of%20our%20journey.%20If%20you%E2%80%99ve%20filed%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fcitusdata%2Fcitus%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eissues%20on%20GitHub%3C%2FA%3E%2C%20submitted%20PRs%2C%20talked%20to%20our%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fcitusdata%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%40citusdata%3C%2FA%3E%20or%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fazuredbpostgres%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%40AzureDBPostgres%3C%2FA%3E%20team%20on%20Twitter%2C%20signed%20up%20for%20our%20monthly%20%3CA%20href%3D%22https%3A%2F%2Fwww.citusdata.com%2Fjoin-newsletter%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ECitus%20technical%20newsletter%3C%2FA%3E%2C%20or%20joined%20our%20%3CA%20href%3D%22https%3A%2F%2Fslack.citusdata.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ECitus%20Public%20community%20Q%26amp%3BA%3C%2FA%3E...%20well%2C%20thank%20you.%20And%20please%2C%20keep%20the%20feedback%20coming.%20You%20can%20always%20reach%20our%20product%20team%20via%20the%20%3CA%20href%3D%22mailto%3AAskAzureDBforPostgreSQL%40service.microsoft.com%3Fsubject%3DAbout%2520Citus%252010%2520in%2520Hyperscale%2520(Citus)%2520blog%2520post%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EAsk%20Azure%20DB%20for%20PostgreSQL%3C%2FA%3E%20email%20address%20too.%3CBR%20%2F%3E%3CBR%20%2F%3EWe%20can%E2%80%99t%20wait%20to%20see%20what%20you%20do%20with%20the%20new%20Citus%2010%20features%20in%20Hyperscale%20(Citus)!%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CSECTION%20role%3D%22doc-endnotes%22%3E%0A%3CP%3E%3CSTRONG%3EFootnotes%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%20id%3D%22ftn1%22%20role%3D%22doc-endnote%22%3EAs%20of%20the%20time%20of%20publication%2C%20in%20the%20East%20US%20region%20on%20Azure%2C%20the%20cost%20of%20a%20Hyperscale%20(Citus)%20Basic%20tier%20with%202%20vCores%2C%208%20GiB%20total%20memory%2C%20and%20128%20GiB%20of%20storage%20on%20the%20coordinator%20node%20is%20%240.27%2Fhour%20or%20~%24200%2Fmonth%20%3CA%20role%3D%22doc-backlink%22%20href%3D%22%23ftnref1%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%E2%86%A9%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FSECTION%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2335404%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Citus10-elephant-drone-release-graphic-against-Azure-blue-with-cloud-1200x630.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279250i1B9B603EDF4CB15E%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Citus10-elephant-drone-release-graphic-against-Azure-blue-with-cloud-1200x630.jpg%22%20alt%3D%22Citus10-elephant-drone-release-graphic-against-Azure-blue-with-cloud-1200x630.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAll%20about%20new%20Citus%2010%20features%20that%20are%20now%20in%20preview%20in%20Hyperscale%20(Citus)%20in%20Azure%20Database%20for%20PostgreSQL.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2335404%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAnnouncements%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Database%20for%20PostgreSQL%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ECitus%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOpen%20Source%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPerformance%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Epostgres%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPostgres%20extensions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Escalability%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎May 07 2021 08:08 PM
Updated by: