Re:

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Andreas Kretschmer *EXTERN*" <akretschmer(at)internet24(dot)de>, <pgsql-de-allgemein(at)postgresql(dot)org>
Subject: Re:
Date: 2012-05-23 14:18:58
Message-ID: D960CB61B694CF459DCFB4B0128514C207EFBC5A@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-de-allgemein

Andreas Kretschmer schrieb:
> Am 23.05.2012 11:06, schrieb Gülümser Köroglu:
[...]
>> Indices auf dieser Tabelle:
>>
>> CREATE INDEX ndalarmhistory_20000000_action_ix
>> ON ndalarmhistory_20000000
>> USING btree
>> (action , ndalarm_id , actiontime DESC);
>>
>>
>>
>> CREATE INDEX ndalarmhistory__20000000_actiontime_ix
>> ON ndalarmhistory_20000000
>> USING btree
>> (actiontime DESC);
>>
>>
>> Abfrage:
>> select ActionTime from NDAlarmHistory where Action = 0 AND
>> NDAlarm_id ='56' order by actiontime desc limit 1

>> Explain Anlayze liefert (constraint_exclusion = on):
>>
[...]
>> " -> Index Scan using ndalarmhistory_0_actionime_ix on ndalarmhistory_0 ndalarmhistory (cost=0.00..1085.45 rows=1 width=8) (actual time=0.136..0.136 rows=0 loops=1)"
>> " Filter: ((action = 0) AND (ndalarm_id = 56::bigint))"
>> " -> Index Scan using ndalarmhistory_15000000_actionime_ix on ndalarmhistory_15000000 ndalarmhistory (cost=0.00..22130.41 rows=1 width=8) (actual time=158.244..158.244 rows=0 loops=1)"
>> " Filter: ((action = 0) AND (ndalarm_id = 56::bigint))"
>> " -> Index Scan using ndalarmhistory_20000000_actionime_ix on ndalarmhistory_20000000 ndalarmhistory (cost=0.00..229801.02 rows=1167 width=8) (actual time=20621.925..20621.925 rows=0 loops=1)"
>> " Filter: ((action = 0) AND (ndalarm_id = 56::bigint))"
[...]
> > "Total runtime: 167307.212 ms"

>> Wenn ich aber nun speziell in einer child tabelle suche:
>>
>> select ActionTime from NDAlarmHistory_20000000 where Action IN(0) AND
>> NDAlarm_id IN ('56') order by actiontime desc limit 1
>>
>> "Limit (cost=0.00..3.45 rows=1 width=8) (actual time=0.020..0.020 rows=0 loops=1)"
>> " -> Index Scan using ndalarmhistory_20000000_action_ix on ndalarmhistory_20000000 (cost=0.00..4027.96 rows=1167 width=8) (actual time=0.018..0.018 rows=0 loops=1)"
>> " Index Cond: ((action = 0) AND (ndalarm_id = 56::bigint))"
>> "Total runtime: 0.042 ms"
>>
>> Extremer Unterschied!
>>
>> Warum wird auch oben nicht der Index benutzt, welches die untere Anfrage
>> benutzt hat ? Vor der Partitionierung wurde der multi column index
>> benutzt und meine Abfragen aus dem selben Volumen (43 Mio) schneller
>> beantwortet.

> 1. Deine Partitionierung paßt nicht zur Abfrage und ist damit hier nicht
> hilfreich.

Stimmt, das ist aber hier, glaube ich, nicht das Problem.

Es ist klar, daß über alle Partitionen abgefragt wird.
Aber warum wird bei jeder dieser Partitionen ein Index gescannt, der
nur "actiontime" enthält? Das heißt doch, der gesamte Index muß durchsucht
werden, nicht?
Dabei gibt es einen Index, der besser ist.

> 2. Dein Index heißt im Explain ndalarmhistory_20000000_actionime_ix, das
> paßt nicht zu den definierten.

Ja, das ist auffällig.

> Ich versteh grad nicht den Sprung für actual time in Deinem Explain,
> daher die Frage: Du kannst Copy&Paste - Fehler ausschließen?

Ich sehe keinen Sprung...

Leider kenne ich mich zu wenig mit Planer bei Partitionierung aus,
um mehr sagen zu können.

Liebe Grüße,
Laurenz

In response to

  • Re: at 2012-05-23 09:49:28 from Andreas Kretschmer

Responses

  • Re: at 2012-05-23 15:01:25 from Andreas Kretschmer - internet24 GmbH

Browse pgsql-de-allgemein by date

  From Date Subject
Next Message Andreas Kretschmer - internet24 GmbH 2012-05-23 15:01:25 Re:
Previous Message akretschmer 2012-05-23 12:19:16