2

I have a Postgres instance building a GIN index. It's looking at about 200,000 rows and it's so far taken about 9 hours. Who knows how long it will take eventually. The problem is that it's using about 2% of CPU when I'd like it to use more like 90%. Is there any way to force it to speed up?

4
  • Are you sure the performance is CPU bound? Commented Mar 16, 2010 at 21:09
  • No I'm not sure. I'm just surprised by the amount of CPU it isn't using. A dump of the whole table comes to 130 MB. It's using 2.6% CPU and 2.7% RAM with enough of each spare. Commented Mar 16, 2010 at 21:13
  • 1
    Did you set a proper amount of RAM for maintenance_work_mem ? Edit: There isn't a lock blocking the making of the index? Commented Mar 16, 2010 at 21:16
  • @Frank - I set maintenance_work_mem to something more sensible and it's now at 99%. I'm much happier! Commented Mar 16, 2010 at 22:17

1 Answer 1

3

The main bottleneck is probably disk IO and not CPU.

If you're on a Windows machine, you can check disk IOs using Process Explorer (freeware), if on Unix, use iostat, sar, DTrace (haven't done the latter in a while so not 100% sure of the best tool)

Sign up to request clarification or add additional context in comments.

3 Comments

The Resource Monitor on Windows also shows this and you can usually easily see there whether the machine is currently CPU-limited or by IO.
Thanks! I'm on unix (Linux & Mac). I'll take a look at the options.
I think it was due to paging, leading to thrashing. The answer was to increase the working memory by set maintenance_work_mem = 102400;.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.