public inbox for [email protected]
help / color / mirror / Atom feedQuery regarding EXPLAIN (ANALYZE,BUFFERS)
2+ messages / 2 participants
[nested] [flat]
* Query regarding EXPLAIN (ANALYZE,BUFFERS)
@ 2017-09-21 10:52 Subramaniam C <[email protected]>
2017-09-21 18:37 ` Re: Query regarding EXPLAIN (ANALYZE,BUFFERS) Pavel Stehule <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Subramaniam C @ 2017-09-21 10:52 UTC (permalink / raw)
To: pgsql-performance
Hi
I wanted to query top 20 rows by joining two tables, one table having
around 1 lac rows and other table having 5 lac rows. Since I am using ORDER
BY in the query so I created compound index with the columns being used in
ORDER BY. Initially index size was 939 MB.
Then I ran EXPLAIN(ANALYZE,BUFFERS) for this query which took around 20
secs as it was not using the compound index for this query. So I drop this
index and created again. The index size now got reduced to 559 MB.
After this if I ran the EXPLAIN(ANALYZE,BUFFERS) for this query it was
using the index and took only 5 secs.
Can you please explain how the index size got reduced after recreating it
and how the query started using the index after recreating?
Thanks and Regards
Subramaniam
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Query regarding EXPLAIN (ANALYZE,BUFFERS)
2017-09-21 10:52 Query regarding EXPLAIN (ANALYZE,BUFFERS) Subramaniam C <[email protected]>
@ 2017-09-21 18:37 ` Pavel Stehule <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Pavel Stehule @ 2017-09-21 18:37 UTC (permalink / raw)
To: Subramaniam C <[email protected]>; +Cc: pgsql-performance
2017-09-21 12:52 GMT+02:00 Subramaniam C <[email protected]>:
> Hi
>
> I wanted to query top 20 rows by joining two tables, one table having
> around 1 lac rows and other table having 5 lac rows. Since I am using ORDER
> BY in the query so I created compound index with the columns being used in
> ORDER BY. Initially index size was 939 MB.
>
> Then I ran EXPLAIN(ANALYZE,BUFFERS) for this query which took around 20
> secs as it was not using the compound index for this query. So I drop this
> index and created again. The index size now got reduced to 559 MB.
>
> After this if I ran the EXPLAIN(ANALYZE,BUFFERS) for this query it was
> using the index and took only 5 secs.
>
> Can you please explain how the index size got reduced after recreating it
> and how the query started using the index after recreating?
>
>
The index can be bloated - when you recreate it or when you use REINDEX
command, then you remove a bloat content. VACUUM FULL recreate indexes too.
Fresh index needs less space on disc (the read is faster), in memory too
and has better structure - a access should be faster.
> Thanks and Regards
> Subramaniam
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2017-09-21 18:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-09-21 10:52 Query regarding EXPLAIN (ANALYZE,BUFFERS) Subramaniam C <[email protected]>
2017-09-21 18:37 ` Pavel Stehule <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox