Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lNAVU-0002IY-9H for pgsql-general@arkaria.postgresql.org; Fri, 19 Mar 2021 08:29:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lNAVT-0003n1-5x for pgsql-general@arkaria.postgresql.org; Fri, 19 Mar 2021 08:29:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lNAVS-0003mq-Tg for pgsql-general@lists.postgresql.org; Fri, 19 Mar 2021 08:29:18 +0000 Received: from mout.gmx.net ([212.227.17.21]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lNAVQ-0008O1-Dk for pgsql-general@lists.postgresql.org; Fri, 19 Mar 2021 08:29:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1616142553; bh=oyWePR4v2nPZu6NBJbLPyc3hDlLCKQaaZ9mv0/LFWX8=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=WzIOoeYW/TB9CEej3irUYx3EImQ6e5mkD1bOGzw7kzyiVFQSWvL7pBw4NVRcbeSEy uwaN58HogibxAlSl1/fVtrH6yxylUT7jTBUnG1I94PvMWfCX67/KR2yEZRLuTMXWpi xHkPMnad45aD6aoEyA2rxB3oCEfz2O/bHuXOqMn8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [10.1.32.157] ([185.40.248.10]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MV67y-1lDiqE3hv4-00SAaE for ; Fri, 19 Mar 2021 09:29:12 +0100 Subject: Re: SELECT is faster on SQL Server To: pgsql-general@lists.postgresql.org References: From: Thomas Kellerer Message-ID: <33b19e80-75da-a455-7e78-a01e14e4d4d6@gmx.net> Date: Fri, 19 Mar 2021 09:29:11 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:dMuuGYMswOyFnXVnT92h4DsVK1a8iMHe5snufcW0HntZ1SvSj+B 6D7K2D+o9dLtvCcCfT93uU/1fpzhbrB2xVhAVALm7t9MhTugfQZkx/8ooWW5GuJTBDlSqpl B2AYCBuBymWT93CCk14kASB+X0NQWirfAxVxUxV3B4YzL412XRWbh+XRa/R42R7Q35R0R1D 9aMsyhAerC9cWGKE5j9Fg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:3Pwbp6FXP6E=:oimvOM+sFoQBlIvZV1FLkf BWQD760EvpniybIrbHDrrwnIT1d1BJL7v8Z9XXmcoaKS/LWu8W7gJIUUAb5FTEwWs0XUAjxa+ 8r9cOZS//1tl084vRnWR328fMiAlaRoYKclSOhyBLEyPwXutVIeWHvy2Yqqr+LTzFTn+r4bVO GK4HdfCnaw4OFWe8lScgQnIPXtgHpiBufKznHQTSD+EmytTpAEqrLM0SJLMxIt9j0+BdHuPzs lZLvklvPvHss43C76OYW+huCsiPGoLSFWfC3R6XV8zP4D8AXZqhz09fcSxS/m9HcR50acFhFi CBruec+aRhjPWq4jN/u15er/Anr+N65pXv1Y2Kr1oASxYfIYq5b1IqBgIUh08aOx9wLC0ZS+A G58ZzfHPLLopw+lrUzH63x3u0bypehQ4KWDMZ0dt2/sSl5S0gbA/65ykWPzRJN0gdaKew8mxQ ate2Uj6Ak/Epr5RYXlbY8UaIsVob3C3wqH6T8xOYv+C3NRC+63lmfIEN9mepme+fz4P+uVi4F 9QO2iD5T2ToNKZMjFr0brEk2aazDAiLscWK0TKg3V6JIlr9GJ4tAJM5+BO/JdjdXoAMMBa6dD MDm4hz39FlmDLXPZNDI7ziO0IkNlPrHtkEb5/a9KyGPFJVuDLw+hbE1iWFc/aqNZcDc3SF5zl JQqVoMluyVPh26fr0CGSGOUhW57y4A9SFYGm4bqzPh3jxi3hLaZBeJAFwij2l7N0i46wZUYSt JNP5ngkGJjlTrSiJaHxg7xw38Zmf5YjIM++meARWxNILgV8MyNclHy0EWgLtloPeZSTyVmE92 g6MdkwaLLzw+A1Twqy7x9cHkORAVkKVDcmpIw5Vbx08totN8/vsKoRMaKlNYD7H8mCvr72ma6 8kXTPSgj9WGc57nji6OA== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Frank Millman schrieb am 19.03.2021 um 09:19: > This may be a non-issue, and I don't want to waste your time. But perhap= s someone can have a look to see if there is anything obvious I have misse= d. > > I am writing a cross-platform accounting app, and I test using Sql > Server on Windows 10 and PostgreSql on Fedora 31. Performance is > usually very similar, with a slight edge to PostgreSql. Now I have a > SELECT which runs over twice as fast on Sql Server compared to > PostgreSql. > Can you change the SELECT statement? Very often "distinct on ()" is faster in Postgres compared to the equivale= nt solution using window functions Something along the lines (for the first derived table): SELECT ... FROM ( SELECT a.source_code_id, SUM(a.tran_tot) AS cl_tot FROM ( SELECT distinct on (location_row_id, function_row_id, source_code_= id) source_code_id, tran_tot FROM prop.ar_totals WHERE deleted_id =3D 0 AND tran_date <=3D '2018-03-31' AND ledger_row_id =3D 1 ORDER BY location_row_id, function_row_id, source_code_id, tran_da= te DESC ) AS a GROUP BY a.source_code_id ) as cl_bal ... Thomas