HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Increase in IO Wait after adding indexes with postgres

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
afterpostgreswaitwithindexesaddingincrease

Problem

I've recently been put in charge of a system that has been fairly untended for a period of time.

The majority of activity is via queued worker jobs based off of data feeds from other systems/data sources.

Via the slow query log I identified a number of slow queries using the PostgreSQL logs and added indexes to address these. This started around 7am or so.

  • Would the addition of these indexes have contributed to the large increase in IO/Wait?



  • What steps can I take to reduce this?

Solution

Yes, adding indexes could cause IO wait to increase.

Perhaps without the index, you are doing a lot of full scans of the table, thousands or millions of blocks, to get just one piece of data. But the IO wait is very low, because the kernel read ahead keeps the pump primed so your process doesn't wait on IO (instead it uses a lot of User CPU to filter through the blocks to find the one row it wants).

With the index, it jumps exactly to the row it needs, but it needs to wait for it get read from disk, because read-ahead doesn't help you out.


What steps can I take to reduce this?

Why does it need to be reduced? Is there an actual problem?

Context

StackExchange Database Administrators Q#139455, answer score: 4

Revisions (0)

No revisions yet.