PostgreSQL does not choose my indexes well

2020-04-23 Thread Arcadio Ortega Reinoso
Hi, I don't understand why postgresql doesn't use clearly the most optimal index for a query in PLAN. Can you help me? create table public.tabla (     cod_tabla bigint not null,     tabla varchar(31) not null,     constraint pk_tabla primary key (cod_tabla) ); create table public.entidad (

Re: PostgreSQL does not choose my indexes well

2020-04-23 Thread Arcadio Ortega Reinoso
El 23/4/20 a las 22:45, Tom Lane escribió: "David G. Johnston" writes: I noticed that too...I suspect its related to the ANALYZE result: Index Scan using idx_tabla_entidad on entidad (cost=0.56..51121.41 rows=1405216 width=20) (actual time=0.037..242.609 rows=1409985 loops=1) Index Cond: ((

Re: PostgreSQL does not choose my indexes well

2020-04-25 Thread Arcadio Ortega Reinoso
I'm also wondering exactly which Postgres version this is. Also a good question. Thanks, Stephen postgresql-12/bionic-pgdg,now 12.2-2.pgdg18.04+1 amd64 [instalado] postgresql-client-12/bionic-pgdg,now 12.2-2.pgdg18.04+1 amd64 [instalado, automático] postgresql-client-common/bionic-pgdg,bioni