Let's assume we have a simple table:
CREATE TABLE objects ( id serial primary key, category INT4 NOT NULL DEFAULT 0, object_type INT4 NOT NULL DEFAULT 0, entered_on TIMESTAMPTZ NOT NULL DEFAULT now() );
(This is simplification, but it contains all necessary columns).
What should I do to be able to quickly get 50 newest objects in given category/object_type (or in many categories/many object_types, or in all categories/object_types), optionally with limiting entered_on “older than …".
Continue reading Getting record by 2 criteria, ordered by third – how to do it quickly?