Re: Sort performance on large tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Charlie Savage wrote:
Hi everyone,

I have a question about the performance of sort.

Note it takes over 10 times longer to do the sort than the full sequential scan.

Should I expect results like this? I realize that the computer is quite low-end and is very IO bound for this query, but I'm still surprised that the sort operation takes so long.

The sort will be spilling to disk, which will grind your I/O to a halt.

work_mem =  16384                        # in Kb

Try upping this. You should be able to issue "set work_mem = 100000" before running your query IIRC. That should let PG do its sorting in larger chunks.

Also, if your most common access pattern is ordered via tlid look into clustering the table on that.
--
  Richard Huxton
  Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
      message can get through to the mailing list cleanly

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux