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 1gyIvR-0001d4-41 for pgsql-performance@arkaria.postgresql.org; Mon, 25 Feb 2019 16:16:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gyIvP-0003aF-Mj for pgsql-performance@arkaria.postgresql.org; Mon, 25 Feb 2019 16:16:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyDhK-0002UO-CU for pgsql-performance@lists.postgresql.org; Mon, 25 Feb 2019 10:41:22 +0000 Received: from n3.nabble.com ([162.255.23.22]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gyDhH-0002Hm-04 for pgsql-performance@postgresql.org; Mon, 25 Feb 2019 10:41:20 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 7303E123B08E3 for ; Mon, 25 Feb 2019 03:41:18 -0700 (MST) Date: Mon, 25 Feb 2019 03:41:18 -0700 (MST) From: Kim To: pgsql-performance@postgresql.org Message-ID: <1551091278468-0.post@n3.nabble.com> Subject: Query slow for new participants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, I have an article query which returns articles enabled for a participant. Article table =E2=80=93 Participant table =E2=80=93 Table in between which = stores the links between the Article and particitpant including characteristics such as enabled. It is possible to search on the articles by number, description,=E2=80=A6 For all of my participants, the articles are return in up to 3 seconds. However, when I add a new participant, which has in fact very few articles enabled, the query takes up to 30 seconds. When running analyse explain, I can see that the execution plan for all participants uses indexes and joins the table in the same order. For the new participant, also indexes are used, but the tables are joined i= n a different order which makes the query very slow. Is there any way how I can make the queries fast for new participants? This is a big problem, because for new participants, speed is even more important. Thank you for your help. -- Sent from: http://www.postgresql-archive.org/PostgreSQL-performance-f205008= 1.html