Skip to content
SQLSimplified
BackendQuestion 38 of 52

Partial Indexes

Problem

You want to speed up queries that fetch active orders: WHERE status = 'pending'. Since only 1% of orders are pending, an index on all orders is wasteful. Write a query that outputs ddl with the value: "CREATE INDEX idx_pending_orders ON orders (customer_id) WHERE status = 'pending'; creates a partial index."

Database Schema

This problem acts as a scratchpad. You will write your own DDL/DML or conceptual queries, so there is no predefined schema.

Try It

Loading playground environment...

Hint

Solution