Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jRiyk-0006TB-SS for pgsql-performance@arkaria.postgresql.org; Thu, 23 Apr 2020 21:01:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jRiyh-0002i1-QH for pgsql-performance@arkaria.postgresql.org; Thu, 23 Apr 2020 21:01:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jRiyh-0002hl-Gs for pgsql-performance@lists.postgresql.org; Thu, 23 Apr 2020 21:01:47 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jRiya-0007sK-Vq for pgsql-performance@lists.postgresql.org; Thu, 23 Apr 2020 21:01:47 +0000 Received: by mail-wr1-x442.google.com with SMTP id s10so8326215wrr.0 for ; Thu, 23 Apr 2020 14:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=rh0w8QVh3Xa17/EGJq2s2XBC5tGLAaEdVvUbPouTOUc=; b=ONLN596yM4sIPblBUe8tzMFoUwTMJ1O25v3aGki1rYWcYCFNOPPJUtuMxx/DCZBu2L im4aIfWZRYbqro2TO+qKmWjo/MYbNDqwLMKXnapiUoIXX0DvYUkCT7vkFCoPslOVEt7p JoPcksSzxRzDLXUy2jSUVjo9dQTr1xBowfXHVXLEe2ci489nFgM2GtUXimzaOFYvo1vX KBBIkZbqhn48eDBB45BYiIlRWRTbsWSn5MFeW5iXOYWQRlC7jvN7G7WG6rD8B+Hy6Gqa jgRPJGG8NRsKQ1KuaCF8UZTgGVG3MQ7eK9ROkCN/segHQHg2FAQC5UqTasGqZyNJR1HI ePvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=rh0w8QVh3Xa17/EGJq2s2XBC5tGLAaEdVvUbPouTOUc=; b=GM/Jv410JGZNHpHwU2VLt2UYtrCWnh4EsnlPRclbGXfnXbLyhLS1kdzEWU5bcesmEW g2YlJkXTMc3mSjzhnAZSdSfXYhjkgESDGg4H+Aakd/O46VcRJ0WEDPSE8tgh5ZWuIJrI AtT1jaY0Te0hO5ePxrUnio7OXc+st+vgag8aIRk0VRqM3N3OwJ5OcYKVmPI2eAYzNlcd rbrI4tVLHiKUZOrMLhjUmAMvoqwME5RyARNA0KpGsBOEASSiWFo4jtU6PETZZ6TTqoYb JfUHNVpBwR8QNn2Q2SYXvkAxQNOAXlvx6ckTaLAjEFlGi0JXmi1PNJYG+RZIKMCPqlFa Y0wQ== X-Gm-Message-State: AGi0Pua0M75LRMx7AUO3l7p+YdLKOKyeyK8S/hmYcPUSRHzdaENsQ/wG D+jHXn4EEyFg+1NyYFYlq9d2Qt4ZjrA= X-Google-Smtp-Source: APiQypKA1f08Y+COfe2qLMkG5vNdT7hF4SC0pG5QJceULtVIr84qsK9v+5rc0xq8Md1Trzl7mm5o7g== X-Received: by 2002:a5d:4712:: with SMTP id y18mr7193159wrq.306.1587675697782; Thu, 23 Apr 2020 14:01:37 -0700 (PDT) Received: from [192.168.2.100] (32.red-80-39-211.dynamicip.rima-tde.net. [80.39.211.32]) by smtp.googlemail.com with ESMTPSA id r3sm5773794wrx.72.2020.04.23.14.01.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Apr 2020 14:01:37 -0700 (PDT) Subject: Re: PostgreSQL does not choose my indexes well To: pgsql-performance@lists.postgresql.org References: <35dc90d6-e0c2-13b8-3184-e3db5d854a78@gmail.com> <1bb37a19-77f6-8c49-073e-ed6251c98583@gmx.net> <4315.1587655779@sss.pgh.pa.us> <20200423171858.GE13712@tamriel.snowman.net> <18681.1587664601@sss.pgh.pa.us> <20200423200143.GK13712@tamriel.snowman.net> <12000.1587673987@sss.pgh.pa.us> <12521.1587674742@sss.pgh.pa.us> From: Arcadio Ortega Reinoso Message-ID: Date: Thu, 23 Apr 2020 23:01:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <12521.1587674742@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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: ((cod_tabla)::bigint = 4) > Yeah, that *strongly* suggests that cod_tabla isn't really bigint. > I'm wondering about domains, for instance. > > regards, tom lane > > Actually CREATE DOMAIN cod_pk AS bigint; create table public.tabla (     cod_tabla cod_pk not null,     tabla varchar(31) not null,     constraint pk_tabla primary key (cod_tabla) ); Do you think is important? Thank you very much to all