pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrus <kobruleht2@hot.ee>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: How to speed up product code and subcode match
Date: Tue, 23 May 2023 10:00:25 -0400
Message-ID: <908933.1684850425@sss.pgh.pa.us> (raw)
In-Reply-To: <7181fbab-1b51-c005-2576-d287fbcd784c@hot.ee>
References: <7181fbab-1b51-c005-2576-d287fbcd784c@hot.ee>

Andrus <kobruleht2@hot.ee> 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 probably have devised a worse data representation if
you really tried, but it would have taken some effort.  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
from toode, vordlusajuhinnak
where toode.toode = vordlusajuhinnak.toode;

Anytime you're trying to join two tables on something that isn't
a plain equality condition (or ANDed conditions), you're in for
a world of hurt.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <908933.1684850425@sss.pgh.pa.us>
Permalink:  ../908933.1684850425@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/908933.1684850425@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, kobruleht2@hot.ee
  Subject: Re: How to speed up product code and subcode match
  In-Reply-To: <908933.1684850425@sss.pgh.pa.us>
  References: <7181fbab-1b51-c005-2576-d287fbcd784c@hot.ee> <908933.1684850425@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox