Re: How to speed up product code and subcode match

2023-05-23 Thread Andrus
Hi! Using index create index on toode ( *split_part( toode, '/',1) *) and query select toode.toode , n2, n3, n4 from toode, vordlusajuhinnak where *split_part( toode.toode, '/',1) *= vordlusajuhinnak.toode; reduces run time to 5 minutes. Andrus. 23.05.2023 17:26 Andrus kirjutas: Hi!

Re: How to speed up product code and subcode match

2023-05-23 Thread Andrus
Hi! Separate the product code and size into two columns --- if there's somebody who really wants to see them in the above format, give them a view or generated column. Then instead of the impossible-to-optimize queries you showed, you could do something like select toode.toode , n2, n3, n4 fro

Re: How to speed up product code and subcode match

2023-05-23 Thread Tom Lane
Andrus writes: > Product table as both main products and subproducts with sizes. Size is > separated by main product code always by / character: >     SHOE1-BLACK >     SHOE1-BLACK/38 >     SHOE1-BLACK/41 >     SHOE1-BLACK/42 >     SHOE1-BLACK/43 >     SHOE2/XXL >     SHOE2/L You could p

Re: How to speed up product code and subcode match

2023-05-23 Thread Andrus
Hi! I ran analyze toode; create index vordlusajuhinnak_toode_pattern_idx on vordlusajuhinnak(toode bpchar_pattern_ops); create index vordlusajuhinnak_toode_idx on vordlusajuhinnak(toode); analyze vordlusajuhinnak; Select runs now more than one hour. Output from explain explain create table

How to speed up product code and subcode match

2023-05-22 Thread Andrus
Hi! Price list of main products vordlusajuhinnak contains 3 prices for product (column toode) and has 39433 products:     create table vordlusajuhinnak( toode varchar(60), n2 numeric(8,2), n3 numeric(8,2), n4 numeric(8,2) ); toode column in unique, may be primary key in table and contains u