Search code examples
sqldatabase-performancedatabase-partitioningpostgresql-11

Querying the entire table VS Querying each partition of the table


Let's say I have a table with multiple partitions and I need to query something from the entire table. Is there a difference, from a performance point of view, between running a single sql query on the entire table and running one sql for each partition?

LE: I'm using Postgres


Solution

  • In Microsoft SQL Server when you create a partition function for partitioning a table, this function partitions data and route the query to the best data file.

    For example if your partition function creates in a datetime field and partition data yearly, your query just run in a single data file that contains your where clause data.

    Therefore you don't need to separate your query and the SQL Server Engine will do that automatically.