Skip to content

Table Clustering and Partitioning #5

@dovydasm

Description

@dovydasm
  • Migrations
  • Scaffolding
CREATE TABLE sales (
    sale_id INT64,
    customer_id INT64,
    product_id INT64,
    store_id INT64,
    sale_date DATE,
    amount NUMERIC
)
PARTITION BY sale_date
CLUSTER BY customer_id, product_id;
 // Time-based partitioning
  modelBuilder.Entity<Order>()
      .PartitionByTime(o => o.OrderDate, BigQueryTimePartitionGranularity.Day)
      .ClusterBy(o => o.CustomerId, o => o.Status);

  // Integer range partitioning
  modelBuilder.Entity<Event>()
      .PartitionByRange(e => e.UserId, start: 0, end: 10000, interval: 100);

  // Ingestion time partitioning
  modelBuilder.Entity<LogEntry>()
      .PartitionByIngestionTime();

modelBuilder.Entity<Order>()
      .PartitionByTime(o => o.OrderDate)
      .HasPartitionExpiration(days: 90)
      .RequirePartitionFilter(true);

https://docs.cloud.google.com/bigquery/docs/clustered-tables

https://hoffa.medium.com/bigquery-optimized-cluster-your-tables-65e2f684594b

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions