Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5Dq4-0005Zi-J3 for pgsql-general@arkaria.postgresql.org; Tue, 03 Sep 2019 18:47:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i5Dq3-0000QV-DY for pgsql-general@arkaria.postgresql.org; Tue, 03 Sep 2019 18:47:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5Dq2-0000Q7-W9 for pgsql-general@lists.postgresql.org; Tue, 03 Sep 2019 18:47:35 +0000 Received: from mail-yw1-xc36.google.com ([2607:f8b0:4864:20::c36]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5Dpz-000107-Vk for pgsql-general@lists.postgresql.org; Tue, 03 Sep 2019 18:47:34 +0000 Received: by mail-yw1-xc36.google.com with SMTP id i207so6167841ywc.9 for ; Tue, 03 Sep 2019 11:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=entrata-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gq+6fxF3Hwm+psSDJto12Tyh48Za8BK3CghabeCAu4E=; b=gjwUQcCpZEafLCnJx8gn8ZYDclp9c4agde8GREtfU6go8q61aS9ujnbQ428X8Kqa+k X4X60unpcWk1Ne4jZ9HI2esU+oNL8du91twVY7PG1Zk4AUHXMbhUIgtopXRe9noVLp2d m76OXMAF+v4ElboXHXra+Rgw7hQErKla22Ezf7MaJIDY5c3Xk/cFrGe7yTdVtVlBcun5 lOGOM+I9jic1pgwaqMXq807F66nyJR2QcAOqjSkVNOWW+EBKw3pEjUlG1ucVFTciQsr3 nz1MhXwDTCvQuOg5UjpTA+OLTtNaRsz8xYq9wTFoySWW/ABOg0ZO76X74QztyyskKXRS egFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Gq+6fxF3Hwm+psSDJto12Tyh48Za8BK3CghabeCAu4E=; b=rmBOecNxFVsLA/IDwVJ2Jtg6O6HyTSES4S6txTQ5CA3x3t6/El8/heCnj8IUaT+1mX +9681u3ZeYLxGbeeTz39TFSqfVwehjW1bdXNAvpoJLIHq6iq9TCwc3lY+FBXHkx20/95 yTkKRv5UAlM4bGw7hwVRf+pxd97a0txVNgDoxAYPg4qUx2P0HJr3E8JWFADCUYWGUsOV Kcg+0Koz1W43Pr/vywviRLIG0iq064Vauhdje5HG1RFpPYmIs71FcgODSGUukJ/wPIzP t6A8cg7kf62U6ZmPCricqcHuIXoNz/023wHqiaKCZik8nfHlQjqtFskLYp6zrxPz8VYg XUQg== X-Gm-Message-State: APjAAAXTgWRp9zZTiZ3glF70LmauuXHdeyAS8HAhTp8mzpP7aH2sNO0V EAPSipYmU6GhDys2TnEgwjdYfjLx5qhhq8+i65VThw== X-Google-Smtp-Source: APXvYqwKHY9581BP7FSwzUnmEEh3lcjSeZfvEZnMNvrPGnnKdpjs2URqaE0xgEFzzIA+yIEeJToBN7v3xGJHTZlTrV0= X-Received: by 2002:a81:414b:: with SMTP id f11mr26775944ywk.334.1567536000203; Tue, 03 Sep 2019 11:40:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Michael Lewis Date: Tue, 3 Sep 2019 12:39:34 -0600 Message-ID: Subject: Re: Bad Estimate for multi tenant database queries To: Peter Grman Cc: PostgreSQL General Content-Type: multipart/alternative; boundary="000000000000771b3e0591aa6a0f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000771b3e0591aa6a0f Content-Type: text/plain; charset="UTF-8" > > CREATE STATISTICS MT_ReservationDepartureUtc (ndistinct) on "AccountCode", > "DepartureUtc" from "Reservation"."Reservation"; > CREATE STATISTICS MT_ReservationArrivalUtc (ndistinct) on "AccountCode", > "ArrivalUtc" from "Reservation"."Reservation"; > CREATE STATISTICS MT_ReservationNoShowFeeId (ndistinct) on "AccountCode", > "NoShowFeeId" from "Reservation"."Reservation"; > CREATE STATISTICS MT_ReservationTimeSliceDefinitionId (ndistinct) on > "AccountCode", "TimeSliceDefinitionId" from "Reservation"."Reservation"; > > but that didn't help either > Did you try with 'dependencies' for the statistics_kind or only ndistinct? What was default_statistics_target set to at the time you created the extended statistics? I am not sure if that value is used, but I would assume so. --000000000000771b3e0591aa6a0f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
CREATE STATISTICS MT_ReservationDe= partureUtc (ndistinct) on "AccountCode", "DepartureUtc"= from "Reservation"."Reservation";
CREATE= STATISTICS MT_ReservationArrivalUtc (ndistinct) on "AccountCode"= , "ArrivalUtc" from "Reservation"."Reservation&quo= t;;
CREATE STATISTICS MT_ReservationNoShowFeeId (ndistinct) on "Acc= ountCode", "NoShowFeeId" from "Reservation"."= Reservation";
CREATE STATISTICS MT_ReservationTimeSliceDefinitionId= (ndistinct) on "AccountCode", "TimeSliceDefinitionId" = from "Reservation"."Reservation";

but that didn't help either
Did you try with 'dependencies' for the statistics_kin= d or only ndistinct? What was default_statistics_target set to at the time = you created the extended statistics? I am not sure if that value is used, b= ut I would assume so.
--000000000000771b3e0591aa6a0f--