As mentioned in the last chapter, Chapter 9, Database Indexing, PostgreSQL is capable of combining indexes together when two of them are relevant for answering a query. The customers table in the Dell Store example has an index on both the customerid and the username. These are both pretty boring bits of data:
SELECT customerid,username from customers limit 3; customerid | username ------------+---------- 1 | user1 2 | user2 3 | user3
The following somewhat contrived query returns only two rows, but it can use both indexes to accelerate that, and, after tweaking the number of values referenced, it's possible to demonstrate that:
SELECT customerid,username FROM customers WHERE customerid<10000 AND username<'user100'; ...