Re: Performance of "distinct with limit"

2020-08-28 Thread Klaudie Willis
No index on n, no. Index might solve it yes, but it seems to me such a trivial optimization even without. Obviously it is not. QUERY PLAN | --| Limit (cost=1911272.10..1911272.12 rows=2 width=7) | -> HashAggregate

Re: Performance of "distinct with limit"

2020-08-28 Thread luis . roberto
Hi, If "n" is indexed, it should run quickly. Can you share the execution plan for your query? De: "Klaudie Willis" Para: "pgsql-general" Enviadas: Sexta-feira, 28 de agosto de 2020 8:29:58 Assunto: Performance of "distinct with limit" Hi, Ran into this under-optimized query executi

Re: Postgres and alias

2020-08-28 Thread Laurenz Albe
On Thu, 2020-08-27 at 12:55 -0300, Fontana Daniel C (Desartec S.R.L.) wrote: > Hi, I am migrating a database from Sybase to PostgreSql 12. > > This select in sybase works for me, but with postgresql it accuses me > "THERE IS NO COLUMN ls_numero" > > select '1234567890' as ls_number, >

Performance of "distinct with limit"

2020-08-28 Thread Klaudie Willis
Hi, Ran into this under-optimized query execution. select distinct n from bigtable; -- Lets say this takes 2 minutes select distinct n from bigtable limit 2 -- This takes approximately the same time However, the latter should have the potential to be so much quicker. I checked the same query o

Re: Postgres and alias

2020-08-28 Thread Stelios Sfakianakis
Hi, Either: SELECT description, SUBSTRING( ls_price_and_date, 8, 13) price, SUBSTRING( ls_price_and_date, 21) date FROM ( SELECT art.description, f_art_get_price_str( art.id ) ls_price_and_date FROM articulos art ) t; Or use a CTE (

Re: Postgres and alias

2020-08-28 Thread Alban Hertroys
> On 28 Aug 2020, at 2:14, Fontana Daniel C (Desartec S.R.L.) > wrote: > > Perfect. > > now let's imagine that '1234567890' is a function f_art_get_price(id_code), > which returns in a string like the following 'XXXZMMM1234567890123/mm/dd' > where 1234567890123 is the price and /mm/d