Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 818D263302F for ; Fri, 19 Mar 2010 15:21:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 07368-07 for ; Fri, 19 Mar 2010 18:20:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pv0-f174.google.com (mail-pv0-f174.google.com [74.125.83.174]) by mail.postgresql.org (Postfix) with ESMTP id A58A7634ED1 for ; Fri, 19 Mar 2010 15:20:49 -0300 (ADT) Received: by pva4 with SMTP id 4so1735713pva.19 for ; Fri, 19 Mar 2010 11:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=/VbpCl07+liu42IVFLi9rv+oP5MJg9Q6hN1eSTD+Ke8=; b=mHPdmfQXZaweHe0sjfTAc3FaYi0faJrFtgKj26SdfGoKwSEgmpwKgxnfIkKHS3PWhz T/FDyFV1SRl6VJ+sXvR6y5vPp7E/MdypxwjDgxHhrWOyn9oNDhGygWpvV6cNOOH4hpWJ stV1ifRxeK0K0SCTgl/dajvmEwhafwGqWfcqs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=m1IPFgpwfBAzGhbht0PSStWgPue0Uwbmqfm4sFh+1nxtipTb6mHLBewCSVdIt2RTFM F9ZjKhczOoRwcAY2mxXzdaTQZmDmZ1WZUc+QG/Y7/CXsilW6A8uZYpn5DP9tXbXYoN4g P1omar0qL03RMC/1B21TvYk6/zz8xV33zTVac= MIME-Version: 1.0 Received: by 10.143.24.15 with SMTP id b15mr2214270wfj.41.1269022848228; Fri, 19 Mar 2010 11:20:48 -0700 (PDT) In-Reply-To: <4BA23936.2030507@gmail.com> References: <4BA23936.2030507@gmail.com> Date: Fri, 19 Mar 2010 14:20:48 -0400 Message-ID: Subject: Re: mysql to postgresql, performance questions From: Merlin Moncure To: Corin Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.597 tagged_above=-10 required=5 tests=AWL=0.002, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/243 X-Sequence-Number: 38068 On Thu, Mar 18, 2010 at 10:31 AM, Corin wrote: > I'm running quite a large social community website (250k users, 16gb > database). We are currently preparing a complete relaunch and thinking about > switching from mysql 5.1.37 innodb to postgresql 8.4.2. The database server > is a dual dualcore operton 2216 with 12gb ram running on debian amd64. > > For a first impression I ran a simple query on our users table (snapshot > with only ~ 45.000 records). The table has an index on birthday_age > [integer]. The test executes 10 times the same query and simply discards the > results. I ran the tests using a php and a ruby script, the results are > almost the same. > > Unluckily mysql seems to be around 3x as fast as postgresql for this simple > query. There's no swapping, disc reading involved...everything is in ram. > > query > select * from users where birthday_age between 12 and 13 or birthday_age > between 20 and 22 limit 1000 couple of points: \timing switch in psql is the best way to get timing results that are roughly similar to what your application will get, minus the overhead of your application. your issue is likely coming from one of three places: 1) connection/ssl/client library issue: maybe you are using ssl in postgres but not mysql, or some other factor which is outside the database 2) not apples to apples: postgres schema is missing an index, or something similar. 3) mysql generated a better plan: mysql has a simpler query planner/statistics model that can occasionally generate a better plan or (if you are using myisam) mysql can do tricks which are impractical or impossible in the mvcc transactional system postgres uses. so, you have to figure out which of those three things you are looking at, and then fix it if the query is performance critical. merlin