1

Actually, all my question is written in subj-field. It's it somehow possible in PostgreSQL? Probably at server-config level, or can be configured in query, or in properties of table? I hardly tried to google for it, but got no result. So your help would be very appreciated (even pointing me to google with correct query, if i'm mistaken. Thanks beforehand.

WesternTune
  • 199
  • 1
  • 1
  • 8
  • 4
    Why do you think you need this? What problem are you trying to solve? –  Feb 16 '11 at 14:17
  • 1
    hardly (= scarcely) vs. hard (= with effort) :) – Draco Ater Feb 16 '11 at 14:26
  • english is not my native, so thanks for correcting me =) – WesternTune Feb 16 '11 at 14:28
  • I'll try to explain. I have table with 10 millions rows in it. Rows are records about actions with accounts, so every row has field "accountId". In every row additional indexes are "accountId" and "date"-fields. Quantity of unique accounts is 1000. – WesternTune Feb 16 '11 at 15:48
  • I perform select-query like "SELECT bla-bla WHERE accountId = '{required account id}' ORDER BY date" and i have next result (everytime reducing quantity of rows in a table and restarting OS). Table with 10'000'000 records is being processed for 27 sec. 1'000'000 records -> 2.7 sec. 500'000 -> 1.3 sec and 100'000 -> 0.3 sec. – WesternTune Feb 16 '11 at 15:51
  • I have strange feeling that 27 seconds for selecting about 10'000 records - it's TOO MUCH. I probably consider that "quicksort" can help better in this situation. Please tell if a can force db to use this method? – WesternTune Feb 16 '11 at 15:52
  • 4
    please provide query plan (EXPLAIN ANALYZE) – Draco Ater Feb 16 '11 at 15:56
  • 2
    Perform analyze on this table, maybe reindex too... and provide us EXPLAIN ANALYZE – Szymon Lipiński Feb 16 '11 at 18:37
  • 3
    How long does your queries take when the ORDER BY clause is removed? – Stephen Denne Feb 16 '11 at 19:55

1 Answers1

3

You cannot. The planner will pick the more appropriate method based on what you're doing:

  • top-n sort if you've an order by / limit with a reasonably small number;
  • quick sort (in memory or on disk) if not.
Denis de Bernardy
  • 75,850
  • 13
  • 131
  • 154