I created an index without specifying ordering or nulls first/last e.g.:
CREATE INDEX index_name ON TABLE table_name (date)
and now my ORDER BY DESC NULLS LAST
queries run extremely slowly.
I read in PostgreSQL documentation, that
NULLS FIRST Specifies that nulls sort before non-nulls. This is the default when DESC is specified.
NULLS LAST Specifies that nulls sort after non-nulls. This is the default when DESC is not specified.
therefore if I create an index like this (for col date
):
CREATE INDEX index_name ON TABLE table_name (date DESC NULLS LAST)
will I get a serious performance gain for queries like
SELECT * FROM table_name ORDER BY date DESC NULLS LAST LIMIT 50 OFFSET 0
?