Re: DATA corruption after promoting slave to master

From: Shaun Thomas <sthomas(at)optionshouse(dot)com>
To: 'Kirit Parmar' <kirit(dot)p(at)directi(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, "Karthik Iyer" <karthik(dot)i(at)directi(dot)com>, Reinwald Warapen <reinwald(dot)w(at)directi(dot)com>
Subject: Re: DATA corruption after promoting slave to master
Date: 2014-11-06 14:09:20
Message-ID: 0683F5F5A5C7FE419A752A034B4A0B9797D9962C@sswchi5pmbx2.peak6.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Krit,

It looks like your actual problem is here:

>  Index Scan using t1_orderid_creationtime_idx on t1
>  (cost=0.43..1181104.36 rows=9879754 width=158)
> (actual time=0.021..60830.724 rows=2416614 loops=1

This index scan estimates 9.8M rows, and had to touch 2.4M. The issue is that your LIMIT clause makes the planner overly optimistic. The worst case cost estimate for this part of the query is about 1.2M, which is much higher than the SEQ SCAN variation you posted. The planner must think it can get the rows without incurring the full cost, otherwise I can't see how the 1.2M cost estimate wasn't rolled into the total estimate.

Unfortunately behavior like this is pretty common when using LIMIT clauses. Sometimes the planner thinks it can get results much faster than it actually can, and it ends up reading a much larger portion of the data than it assumed would be necessary.

Just out of curiosity, Can you tell me what your default_statistics_target is?

______________________________________________

See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Edoardo Panfili 2014-11-06 14:34:47 psql connection via localhost or 127.0.0.1
Previous Message Rémy-Christophe Schermesser 2014-11-06 12:56:45 Re: Performance problem on 2 PG versions on same query