Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I second Gordon's points and will add my own experiences with cache misses. Basically what happens is that at a certain point data in the cache ends up expiring, and suddenly you have a significant amount of disk I/O.</p> <p>I did a bulk payment stored procedure for a customer, and for small payment batches it worked perfectly but for large ones, it would choke. After some testing we noticed the following:</p> <p>when up to a few hundred invoices were paid, it would perform very well. With 200-500 invoices paid for a vendor it would start to slow down, and with 1000 or more invoices paid for a vendor, it would seem to hang. I talked to a PostgreSQL guru who looked over the code and immediately suggested a cache miss. We rewrote the code with this in mind and performance became tolerable.</p> <p>What I would recommend doing in your case is to figure out exactly what needs to be retrieved from the application perspective and writing your query to do as much as possible within that query. I don't know exactly what you are doing so I don't know if sorting is enough. However I have seen HAVING clauses solve performance issues like these so it is worth looking not only at sorting but also aggregation and also whether the initial query in any way combines reads with writes (such as through a function call in the field list). This is always a performance killer and will make cache misses exceptionally painful (that was in fact a major issue in my learning experience mentioned above).</p> <p>In general my experience with PostgreSQL is that your performance is always best when you get exactly the information the application needs, and as much of the set processing logic is pushed into the db.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload