[PERFORM] query performance with hstore vs. non-hstore

2014-09-01 Thread Huang, Suya
Hi , I'm tweaking table layout to get better performance of query. One table doesn't use hstore but expand all metrics of cha_type to different rows. The other table has hstore for metrics column as cha_type-metrics so it has less records than the first one. I would be expecting the query on

Re: [PERFORM] query performance with hstore vs. non-hstore

2014-09-01 Thread Pavel Stehule
Hi In this use case hstore should not help .. there is relative high overhead related with unpacking hstore -- so classic schema is better. Hstore should not to replace well normalized schema - it should be a replace for some semi normalized structures as EAV. Hstore can have some profit from

Re: [PERFORM] query performance with hstore vs. non-hstore

2014-09-01 Thread Huang, Suya
Thank you Pavel. The cost of unpacking hstore comparing to non-hstore could be calculated by: Seq scan on hstore table + hash join with seg1 table: Hstore: 416.741+ 34619.879 =~34 seconds Non-hstore: 8858.594 +26477.652 =~ 34 seconds The subsequent hash-aggregate and sort operation should be

Re: [PERFORM] query performance with hstore vs. non-hstore

2014-09-01 Thread Pavel Stehule
2014-09-01 8:54 GMT+02:00 Huang, Suya suya.hu...@au.experian.com: Thank you Pavel. The cost of unpacking hstore comparing to non-hstore could be calculated by: Seq scan on hstore table + hash join with seg1 table: Hstore: 416.741+ 34619.879 =~34 seconds Non-hstore: 8858.594

Re: [PERFORM] query performance with hstore vs. non-hstore

2014-09-01 Thread Huang, Suya
Hi Pavel, See output of explain (analyze,timing off), the total runtime is close to the one enable timing. dev=# EXPLAIN (ANALYZE, TIMING OFF) select cha_type,sum(visits) from weekly_non_hstore a join seg1 b on a.ref_id=b.ref_id group by cha_type order by sum(visits) desc;

Re: [PERFORM] query performance with hstore vs. non-hstore

2014-09-01 Thread David G Johnston
Huang, Suya wrote See output of explain (analyze,timing off), the total runtime is close to the one enable timing. Calling 43s close to 70s doesn't sound right... dev=# explain (analyze, timing off) select cha_type, sum(visits) from (select (each(visits)).key as