Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aXC3G-0007yG-CA for pgsql-performance@arkaria.postgresql.org; Sat, 20 Feb 2016 18:14:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aXC3E-0005Bz-PQ for pgsql-performance@arkaria.postgresql.org; Sat, 20 Feb 2016 18:14:40 +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_SHA384:256) (Exim 4.84) (envelope-from ) id 1aXC3D-0005B1-0U for pgsql-performance@postgresql.org; Sat, 20 Feb 2016 18:14:39 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aXC37-0005ZZ-E7 for pgsql-performance@postgresql.org; Sat, 20 Feb 2016 18:14:38 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E7662202DD for ; Sat, 20 Feb 2016 13:14:29 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Sat, 20 Feb 2016 13:14:29 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=SK39ZYnzIAhS/j1d3ZZ0v+rZt2s=; b=bMSpuZ A/pv0kT513U+dm9LgT+MkhdhL4QqnQXxM3NqKw+bcVaVKXHbkbItjWyyHKIEcJNl SuPvO5Z5QWNGofPACl4m9hvUgQZKfs/Z997ClJh55ioZTfTfgP7jI/oK9q5mo3dj K2fZFcbNKeMmfhYSYDFvSebPksVmL3FTQFV4I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=SK39ZYnzIAhS/j1 d3ZZ0v+rZt2s=; b=tCz6OtI7YsBPYcNlOi9DI/gBDgTTfMc2mVs8Cw+2SZ+0VnO hyP+M8Zx0QgAaZxlu6j9rpyAJbGFse0WxnQ3PD/XE9pBw907xxdL+PFnVfD7D5uW EHVRZ72r3ZP+XvZZu39MEboYmoexjf4/6j4+zlPqMDC0RLS4nEL5uy3kuD8g= X-Sasl-enc: yZHdKs75lgeG+Fcgqc3EHd08zPSWQfVUGCqw72pvLNg3 1455992069 Received: from [192.168.1.2] (174-21-70-246.tukw.qwest.net [174.21.70.246]) by mail.messagingengine.com (Postfix) with ESMTPA id 45B19680195; Sat, 20 Feb 2016 13:14:29 -0500 (EST) Subject: Re: [GENERAL] Why Postgres use a little memory on Windows. To: tuanhoanganh , PostgreSQL , pgsql-performance References: From: Adrian Klaver Message-ID: <56C8ACBE.60004@aklaver.com> Date: Sat, 20 Feb 2016 10:13:18 -0800 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 02/20/2016 08:46 AM, tuanhoanganh wrote: > Hello > > I have a bad query on PostgreSQL 9.0.23 - 64bit - Windows 2012 R2 - 48GB Ram > > explain analyze select d.data_id, d.table_name, d.event_type, > d.row_data, d.pk_data, d.old_data, d.create_time, d.trigger_hist_id, > d.channel_id, d.transaction_id, d.source_node_id, d.external_data, '' > from sym_data d inner join sym_data_gap g on g.status='GP' and d.data_id > between g.start_id and g.end_id where d.channel_id='sale_transaction' > order by d.data_id asc; Took liberty of reformatting the above here: http://sqlformat.darold.net/ EXPLAIN ANALYZE SELECT d.data_id, d.table_name, d.event_type, d.row_data, d.pk_data, d.old_data, d.create_time, d.trigger_hist_id, d.channel_id, d.transaction_id, d.source_node_id, d.external_data, '' FROM sym_data d INNER JOIN sym_data_gap g ON g.status = 'GP' AND d.data_id BETWEEN g.start_id AND g.end_id WHERE d.channel_id = 'sale_transaction' ORDER BY d.data_id ASC; The thing that stands out to me is that I do not see that sym_data and sym_data_gp are actually joined on anything. Also is it possible to see the schema definitions for the two tables? > > Here is result > > Nested Loop (cost=319.42..4879348246.58 rows=32820035265 width=1525) (actual time=64656.747..5594654.189 rows=3617090 loops=1) > -> Index Scan using sym_data_pkey on sym_data d (cost=0.00..3671742.82 rows=3867095 width=1525) (actual time=9.775..12465.153 rows=3866359 loops=1) > Filter: ((channel_id)::text = 'sale_transaction'::text) > -> Bitmap Heap Scan on sym_data_gap g (cost=319.42..1133.51 rows=8487 width=8) (actual time=1.438..1.439 rows=1 loops=3866359) > Recheck Cond: ((d.data_id >= g.start_id) AND (d.data_id <= g.end_id)) > Filter: (g.status = 'GP'::bpchar) > -> Bitmap Index Scan on sym_data_gap_pkey (cost=0.00..317.30 rows=8487 width=0) (actual time=1.436..1.436 rows=1 loops=3866359) > Index Cond: ((d.data_id >= g.start_id) AND (d.data_id <= g.end_id)) > > http://explain.depesz.com/s/c3DT > > > I have run vaccum full. Here is my PostgreSQL config > > shared_buffers = 2GB > work_mem = 64MB > maintenance_work_mem = 1GB > wal_buffers = 256 > effective_cache_size = 4GB > checkpoint_segments = 256 > wal_level = hot_standby > max_wal_senders = 5 > wal_keep_segments = 256 > random_page_cost = 3.5 > autovacuum_vacuum_threshold = 1000 > autovacuum_analyze_threshold = 250 > max_locks_per_transaction = 2000 > > When I check taskmanager, I found postgres process is user 4-5MB > > What happened with my PostgreSQL. Please help me > > Thank you in advance. > > Tuan Hoang Anh > > > -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance