Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Top Partitions by Resource Use
00:00
5 left

Top Partitions by Resource Use

MediumSQL · PostgreSQL

Problem

Write a query to identify top-performing partitions based on resource consumption.

Use the partition catalog and resource usage data. Treat higher total credits consumed as better performance for this task. Return the highest-ranked partitions, including ties at the third rank.

Output

  1. One row per qualifying partition with partition_id, table_name, total_credits_used, total_bytes_scanned, and resource_rank
  2. Include partitions ranked 1 through 3, including ties
  3. Order by resource_rank, descending total_credits_used, then ascending partition_id

Schema

partition_catalog
ColumnTypeDescription
partition_idPKINTUnique partition identifier
database_nameVARCHAR(100)Snowflake database containing the table
schema_nameVARCHAR(100)Snowflake schema containing the table
table_nameVARCHAR(100)Table containing the partition
partition_labelVARCHAR(100)Human-readable partition label
partition_resource_usage
ColumnTypeDescription
usage_idPKINTUnique resource usage record
partition_idINTReferenced partition identifier
query_idVARCHAR(50)Query associated with the usage record
credits_usedDECIMAL(12,2)Credits consumed by the query
bytes_scannedBIGINTBytes scanned for the partition
execution_msINTQuery execution time in milliseconds
Tablespartition_catalogpartition_resource_usage
Interviewer

Your question is Top Partitions by Resource Use. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.