Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0aIj-0000Ts-AL for pgsql-performance@arkaria.postgresql.org; Thu, 13 Sep 2018 22:41:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g0aIh-0002cf-JS for pgsql-performance@arkaria.postgresql.org; Thu, 13 Sep 2018 22:41:27 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0aIh-0002bi-7D for pgsql-performance@lists.postgresql.org; Thu, 13 Sep 2018 22:41:27 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g0aIe-0007Mt-Fp for pgsql-performance@postgresql.org; Thu, 13 Sep 2018 22:41:25 +0000 Received: by mail-pl1-x643.google.com with SMTP id b12-v6so3240367plr.8 for ; Thu, 13 Sep 2018 15:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=mpHpmEOfdEgLbnKuie5Oag+//l+ByFpyTHoGotwPO1M=; b=YYQRKuJVprs/yaHv847IBFyF3GnNv+cDWxhgwzK+6RZ8mt2KNM+WXX3dKHBVy9IGfV Wz7bfdDaaPff44U8ZfUyJKwQrQaEVNvLL8PrYhx16IvLroo7ianLxlx0J4TC0N1Fqlxz VACkvxvuiavi+7N124T9/76BKT35LWNkDaBuPT/Ce3AjupYBbE92HK+IgXTmf1hc7VYS 3Eoa4ya33OZU2ljN+hzaD9Wf0lfmR6R0OdupFY/XQJhkM9FOIgwE6iTBZbmwGleoLy5N +cuu2mbuweV+YNIDADEeRkVzzsdKLFHRzMheSSvMQweN5Y/VPWn0Nj2WLly8lRjgLLr0 +OUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=mpHpmEOfdEgLbnKuie5Oag+//l+ByFpyTHoGotwPO1M=; b=IZJiMntOBqTCh/RWu/JLjfHKLepbcG4FosFnYkoz+iheNBBuTGoLrpQEjHbMNzxBPi sTaMviSz3/DtVCoHksyiKHc6gSqlhz4I7BpuFa1VNxLn4y0TbIRUjz0Ta9SskMr4AJEK OtCLoF6TMy5+xDsJL6pZcJkLslEXUTQCjaQUOdEFl0ZVOp7+oMMKyRpmY7QgCQoGu9Ie 7I7+V/0Ml5IzSgpAe+/NMIls4Hpp9Mz+oaaVmqTajwg2KF33e+FloS4WwvZQkKYUy68X 9JIMpcYRAQHL5DqcgEQmLLiCTgwMHXwU5+m0hALrY+uck6ur8hHfd19y0wO/8CwFk2vJ 15HA== X-Gm-Message-State: APzg51BAaL/buLvh7FfsjnAdkfplR6O+98yU/vMWvb6J+N5W+lf2+0bp wKNsYJefJEItpI5yjYkJ1TvguY4N X-Google-Smtp-Source: ANB0VdYeNKsPrpXku8Ns80a40WFrF7uJEayPgCk7DpoUO000x8aULvp+7BL7/A/NAB/n1Q4NpnC1/g== X-Received: by 2002:a17:902:8e81:: with SMTP id bg1-v6mr9271543plb.129.1536878482911; Thu, 13 Sep 2018 15:41:22 -0700 (PDT) Received: from tim-desktop (2001-44b8-31f2-bb00-9db4-4e31-3b73-229c.static.ipv6.internode.on.net. [2001:44b8:31f2:bb00:9db4:4e31:3b73:229c]) by smtp.gmail.com with ESMTPSA id s27-v6sm8598647pfk.133.2018.09.13.15.41.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Sep 2018 15:41:22 -0700 (PDT) References: <1536339842382-0.post@n3.nabble.com> <8736uk6eh5.fsf@gmail.com> <1536385261054-0.post@n3.nabble.com> <87zhwq48ap.fsf@gmail.com> <1536554876104-0.post@n3.nabble.com> <1536843459130-0.post@n3.nabble.com> User-agent: mu4e 0.9.18; emacs 26.1 From: Tim Cross To: padusuma Cc: pgsql-performance@postgresql.org Subject: Re: Performance of INSERT into temporary tables using psqlODBC driver In-reply-to: <1536843459130-0.post@n3.nabble.com> Date: Fri, 14 Sep 2018 08:41:18 +1000 Message-ID: <87tvmtvx4h.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk padusuma writes: > Hello Tim, > > I have tried the suggestions provided to the best of my knowledge, but I did > not see any improvement in the INSERT performance for temporary tables. The > Linux host on which PostgreSQL database is installed has 32 GB RAM. > Following are current settings I have in postgresql.conf file: > shared_buffers = 8GB > temp_buffers = 256MB > work_mem = 256MB > maintenance_work_mem = 256MB > wal_buffers = 256MB > > checkpoint_timeout = 30min > checkpoint_completion_target = 0.75 > max_wal_size = 1GB > > effective_cache_size = 16GB > >>>- Increase work_mem to reduce use of temp files. Need it to be 2 to 3 >>> times largest temp file (but use common sense) > >>I have already increased the work_mem and maintenance_work_mem to 256MB. I >>will check on the temp file sizes and adjust the work_mem parameter as you >>suggested. > >>- Tweak wal checkpoint parameters to prevent wal checkpoints occurring >> too frequently. Note that there is a play off here between frequency >> of checkpoints and boot time after a crash. Fewer wal checkpoints will >> usually improve performance, but recovery time is longer. > >>How effectively you can increase insert times will depend on what the >>memory and cpu profile of the system is. More memory, less use of temp >>files, faster system, so spend a bit of time to make sure your system is >>configured to squeeze as much out of that RAM as you can! > > Please let me know if there are any other suggestions that I can try. How are you gathering metrics to determine if performance has improved or not? Have you seen any change in your explain (analyze, buffers) plans? Make sure your table statistics are all up-to-date before performing each benchmark test. I often turn off autovacuum when doing this sort of testing so that I know exactly when tables get vacuumed and statistics get updated (just ensure you remember to turn it back on when your finished!). Are the wal checkpoints being triggered every 30 mins or more frequently? Are you still seeing the system use lots of temp files? Do you have any indexes on the tables your inserting into? As mentioned previously, there are no simple/quick fixes here - you cannot just change a setting and see performance improve. It will be necessary to do a lot of experimentation, gathering statistics and investigate how postgres is using buffers, disk IO etc. All of these parameters interact with each other, so it is critical you have good metrics to see exactly what your changes do. It is complex and time consuming. Highly recommend PostgreSQL: High Performance (Ahmed & SMith) and Mastering Postgres (Shonig) for valuable background/tips - there really is just far too much to communicate effectively via email. Tim -- Tim Cross