Re: [PERFORM] what's the slowest part in the SQL

2016-08-09 Thread Suya Huang
: 2.640 ms dev=# select pg_size_pretty(pg_relation_size('order')); pg_size_pretty 516 MB (1 row) Thanks, Suya On 8/10/16, 11:57 AM, "Tom Lane" wrote: Suya Huang writes: > Thank you Tom very much, that’s the piece of information I miss. > So, shoul

Re: [PERFORM] what's the slowest part in the SQL

2016-08-09 Thread Suya Huang
at 9:46 PM, Claudio Freire wrote: > On Tue, Aug 9, 2016 at 9:34 PM, Suya Huang wrote: >> dev=# explain analyze >> SELECT COALESCE(w.displayname, o.name) FROM order o INNER JOIN data w >> ON w.name = o.name WHERE (w.name LIKE '%dog%' OR w.displayname LIKE >>

Re: [PERFORM] what's the slowest part in the SQL

2016-08-09 Thread Suya Huang
Thank you Tom very much, that’s the piece of information I miss. So, should I expect that the nested loop join would be much faster if I cache both tables (use pg_prewarm) into memory as it waives the disk read? Thanks, Suya On 8/10/16, 10:45 AM, "Tom Lane" wrote: Suya Hua

Re: [PERFORM] what's the slowest part in the SQL

2016-08-09 Thread Suya Huang
0.022..0.022 rows=3 loops=1) Index Cond: ((displayname)::text ~~ '%dog%'::text) -> Index Scan using idx_order_1_us on order o (cost=0.56..8.58 rows=1 width=30) (actual time=0.025..0.026 rows=0 loops=526) Index Co

Re: [PERFORM] what's the slowest part in the SQL

2016-08-09 Thread Suya Huang
seconds, sounds slow to me. Is that normal? Thanks, Suya On 8/10/16, 9:52 AM, "Claudio Freire" wrote: On Tue, Aug 9, 2016 at 8:27 PM, Suya Huang wrote: > I’ve got a SQL runs for about 4 seconds first time it’s been executed,but > very fast (20ms) for the consequent runs. I thou

[PERFORM] what's the slowest part in the SQL

2016-08-09 Thread Suya Huang
Hi, I’ve got a SQL runs for about 4 seconds first time it’s been executed,but very fast (20ms) for the consequent runs. I thought it’s because that the first time table being loaded into memory. However, if you change the where clause value from “cat” to “dog”, it runs about 4 seconds as it’s n