Skip to content

Instantly share code, notes, and snippets.

View koeninger's full-sized avatar

Cody Koeninger koeninger

View GitHub Profile
@sumedhpathak
sumedhpathak / Composite_types.md
Last active October 21, 2016 11:21
Hash partitioning for composite types

Steps for hash-partitioning on composite types

  • Create the type on the master and all worker nodes:
CREATE TYPE new_composite_type as (project_key text, date text);
  • Create a function for checking equality, and associate it with the equality operator for the new type
@marcocitus
marcocitus / citus_tools.sql
Last active September 20, 2016 20:55
Function to run a SQL command across all workers, shards, or placements on Citus
CREATE OR REPLACE FUNCTION citus_shard_name(table_name regclass, shard_id bigint)
RETURNS text
LANGUAGE sql
AS $function$
SELECT table_name||'_'||shard_id;
$function$;
CREATE OR REPLACE FUNCTION citus_shard_name(shard_id bigint)
RETURNS text
LANGUAGE sql