Re: [GENERAL] update inside function does not use the index

2015-11-16 Thread Johannes
That solves my problem. Thanks!! Best regards Johannes Am 16.11.2015 um 18:19 schrieb Tom Lane: > Adrian Klaver writes: >> On 11/16/2015 08:03 AM, Johannes wrote: In every loop I execute an update with a where LIKE condition, which relates to my current cursor position: FOR i IN S

Re: [GENERAL] update inside function does not use the index

2015-11-16 Thread Johannes
A function seams to be atomic for the analyze command (or?) EXPLAIN ANALYZE select my_function(); returns no inner query plan, just the costs, rows and width Am 16.11.2015 um 17:57 schrieb Adrian Klaver: > EXPLAIN ANALYZE select ... your_function(...); signature.asc Description: OpenPGP d

Re: [GENERAL] update inside function does not use the index

2015-11-16 Thread Johannes
No, i did a mistake while simplifying it. It should be FOR i IN SELECT id, level, path_names||'%' as path_names from x LOOP update x set path_ids[i.level] = i.id where path_names like i.path_names; Sorry. Best regards Johannes Am 16.11.2015 um 15:10 schrieb Adrian Klaver: > On 11/16/2015 05:56

Re: [GENERAL] update inside function does not use the index

2015-11-16 Thread Johannes
This helps me to understand for these common table expressions better. Thanks. This looks more elegant than the cursor variant. Limiting the cte to 10 records the update query needs 1.8 seconds. But the cursor variant ( 10 records ) was finished in 0.7 seconds. I guess it is faster, because behind

Re: [GENERAL] update inside function does not use the index

2015-11-16 Thread Tom Lane
Adrian Klaver writes: > On 11/16/2015 08:03 AM, Johannes wrote: >>> In every loop I execute an update with a where LIKE condition, which >>> relates to my current cursor position: >>> FOR i IN SELECT id, level_ids, path_names||'%' as path_names from x LOOP >>> update x set path_ids[i.level] = id w

Re: [GENERAL] update inside function does not use the index

2015-11-16 Thread Adrian Klaver
On 11/16/2015 08:03 AM, Johannes wrote: Ccing list No, i did a mistake while simplifying it. It should be FOR i IN SELECT id, level, path_names||'%' as path_names from x LOOP update x set path_ids[i.level] = i.id where path_names like i.path_names; So what do you see if you do?: EXPLAIN AN

Re: [GENERAL] update inside function does not use the index

2015-11-16 Thread Thomas Kellerer
Johannes schrieb am 16.11.2015 um 14:56: > I have problems with a self written function, which does not use the > index, which takes very long (500 ms per update). > > The pl/pgsql function iterates over a select resultset with a cursor. > In every loop I execute an update with a where LIKE condit

Re: [GENERAL] update inside function does not use the index

2015-11-16 Thread Adrian Klaver
On 11/16/2015 05:56 AM, Johannes wrote: Dear List, I have problems with a self written function, which does not use the index, which takes very long (500 ms per update). The pl/pgsql function iterates over a select resultset with a cursor. In every loop I execute an update with a where LIKE co

[GENERAL] update inside function does not use the index

2015-11-16 Thread Johannes
Dear List, I have problems with a self written function, which does not use the index, which takes very long (500 ms per update). The pl/pgsql function iterates over a select resultset with a cursor. In every loop I execute an update with a where LIKE condition, which relates to my current curso