X-Original-To: pgsql-admin@postgresql.org Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id C89A6474E4F for ; Fri, 21 Mar 2003 05:07:12 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id AEB0743A611; Fri, 21 Mar 2003 05:07:12 -0500 (EST) From: "Gaetano Mendola" X-Newsgroups: comp.databases.postgresql.admin Subject: Index not used on a DISTINCT ON Date: Fri, 21 Mar 2003 11:07:22 +0100 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 30 Message-ID: Reply-To: "Gaetano Mendola" X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 To: pgsql-admin@postgresql.org X-Archive-Number: 200303/335 X-Sequence-Number: 7975 Hi all, I have a table with two column: id_user and login; and the column login is a Primary Key. If I made the following view: CREATE VIEW foo SELECT DISTINCT ON ( login ) ul.id_login AS login, ud.last_name AS last_name, FROM user_login ul LEFT JOIN v_user_traffic v USING ( id_user) user_data ud WHERE ul.id_user = ud.id_user; when is used in this way: SELECT * FROM foo WHERE login = 'XXXXXX'; the index is not used if I remove the DISTINCT ON the filter is used!!! Is it a known issue ?