From the course: Advanced SQL for Application Development

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Querying partitioned tables

Querying partitioned tables

From the course: Advanced SQL for Application Development

Start my 1-month free trial

Querying partitioned tables

- [Narrator] When we use partition tables, we want to keep in mind our partitioning logic when we're writing queries against those tables. We need to keep in mind our partition key. Now again, the partition key determines where a row is stored and so when you write queries, when you write select statements in sequel, you want to be sure to use a partition key or reference the partition key in the where clause whenever possible, so for example, writing a select statement using a partition key might look something as simple as this. So here I have a table called sales history and I want to select where month equals three. That allows us to focus on the partition where the partition key has a value of three, so if you don't use a partition key in the where clause, then you risk scanning all of the different partitions, which can undermine the utility and the benefits of the using partitioning, so that's why we want to keep in…

Contents