Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TTCFe-0005dV-Kc for pgsql-performance@postgresql.org; Tue, 30 Oct 2012 13:53:06 +0000 Received: from smtp2.peak6.com ([38.98.137.9]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TTCFc-00035t-HK for pgsql-performance@postgresql.org; Tue, 30 Oct 2012 13:53:05 +0000 X-AuditID: 0a02cb20-b7f726d000005255-48-508fdbbef43e Received: from sswchi5pcas2.peak6.net (sswchi5pcas2.peak6.net [10.100.13.24]) by smtp2.peak6.com (Symantec Messaging Gateway) with SMTP id 37.E7.21077.EBBDF805; Tue, 30 Oct 2012 08:53:02 -0500 (CDT) Received: from [10.10.201.64] (10.10.201.64) by sswchi5pcas2.peak6.net (10.100.13.25) with Microsoft SMTP Server (TLS) id 14.2.247.3; Tue, 30 Oct 2012 08:53:02 -0500 Message-ID: <508FDBBC.2010807@optionshouse.com> Date: Tue, 30 Oct 2012 08:53:00 -0500 From: Shaun Thomas Reply-To: Organization: Peak6 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: Vincenzo Melandri CC: Subject: Re: Seq scan on 10million record table.. why? References: In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed content-transfer-encoding: 7bit X-Originating-IP: [10.10.201.64] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphleLIzCtJLcpLzFFi42LhSuGV0N13uz/AYMp8XYvrM88xW0zt2szk wOSx+dQaJo8L+6axBzBFNTDaJObl5ZcklqQqpKQWJ9sq+ReUZObnFXvklxanKrhkFifnJGbm phYpKWSm2CoZKykU5CQmp+am5pXYKiUWFKTmpSjZcSlgABugssw8hdS85PyUzLx0WyXPYH9d CwtTS11DJbt4ZJDQyZLxaPU09oJf3BVzT25mbWA8xdnFyMEhIWAisW91dBcjJ5ApJnHh3nq2 LkYuDiGBE4wSE889g3JWMkosvreSFaSKV0Bf4vHcc6wgzSwCqhL/J0uDhNkEdCUm9a9gA7GF BFQk+s7eYAKx+QWEJfZ9aGIGsUUFwiSW79zMBDFGUOLkzCcsILYIUO+W6TMZQWxmATWJuQ8n ga0SFnCQaL6ykBFklZBAgETXTGUQk1MgUGLyZxaIaguJxW8OskPY8hLb385hhrhAVWJF80Q2 iLcUJP5fecc0gVFkFpLFs5C0z0LSvoCReRWjeHFZYnJGpllBcW5JgZFeQWpitpleXmrJJkZQ lDOdVtjBuLnH6hCjAAejEg+vwLa+ACHWxLLiytxDjBIczEoivLfP9wcI8aYkVlalFuXHF5Xm pBYfYvQBBthEZinR5HxgAsoriTc0NjUwtTQ1NDU3NTTCIawkznvpdluAkEA6MO1kp6YWpBbB jGPi4JRqYFS5J+htXCqsK5C86pcr69JJyjdWxvOyO8fyhjyUqj1/IMxe00dHZ6WnvWSNoHWE 6GOW21efvjSOZ+aNyuyy+774lnzrB5mHl8x1LktPCaia/HsuV4L0ZzWJc0d2233Sn31NSDHi jVHah2zvuGNlB2y6TzKLLG/ZvJPpjvjKVxVvTjlVrJlerMRSnJFoqMVcVJwIAHOtk3IfAwAA X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201210/380 X-Sequence-Number: 48339 On 10/30/2012 07:15 AM, Vincenzo Melandri wrote: > Merge Join (cost=2604203.98..2774528.51 rows=129904 width=20) > Merge Cond: (((( big_table.key1)::numeric) = > data_sequences_table.key1) AND ((( big_table.key2)::numeric) = > data_sequences_table.key2)) > -> Sort (cost=2602495.47..2635975.81 rows=13392135 width=20) > Sort Key: ((big_table.key1)::numeric), ((big_table.key2)::numeric) > -> Seq Scan on big_table (cost=0.00..467919.35 rows=13392135 width=20) > -> Sort (cost=1708.51..1709.48 rows=388 width=32) > Sort Key: data_sequences_table.key1, data_sequences_table.key2 > -> Seq Scan on data_sequences_table (cost=0.00..1691.83 > rows=388 width=32) > Filter: (import_id = 1351592072::numeric) As always, we need to see an EXPLAIN ANALYZE, not just an EXPLAIN. We also need to know the version of PostgreSQL and your server settings. Please refer to this: http://wiki.postgresql.org/wiki/Slow_Query_Questions I see a lot of NUMERIC conversions in there, which suggests you're using NUMERIC for your keys. That's not really recommended practice, but also suggests the possibility that all your types are not the same. So it would be very helpful to also see the actual CREATE TABLE, and CREATE INDEX statements for those tables. We can't help you with this limited information. Sorry. -- Shaun Thomas OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604 312-444-8534 sthomas@optionshouse.com ______________________________________________ See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email