Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id C2BA21337B43 for ; Sat, 30 Apr 2011 15:01:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 98956-07 for ; Sat, 30 Apr 2011 18:00:58 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) by mail.postgresql.org (Postfix) with ESMTP id D4EFF1337990 for ; Sat, 30 Apr 2011 15:00:57 -0300 (ADT) Received: by qyg14 with SMTP id 14so2437562qyg.19 for ; Sat, 30 Apr 2011 11:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:references:from:in-reply-to:mime-version:date :message-id:subject:to:cc:content-type; bh=VZFwj5ZjuEMpsuoy4I27v3MG7hPmDai8+5mx6muejdw=; b=r0wsoaHZojz9Hek+E4Fc1/khnMkxAQSRiev8EFRZf1re+qXvkbO/5UA50JShvK/5f4 c9u7bfOkt0PjQP0ugDHG6XnQcZJgqdVWI5HefrC/H+9yPP53mVDVbbBa5zd5itXun0Pd jr//jQunNSuGmMt8bnk3JLh9U+/oDvCbLN90Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :cc:content-type; b=k+nO7yTLFBeEbzAalyJAUFzji4MjKbPJbMaf/3kVIgmRHmzXeUmmp+gqX4zlgtcJl4 CrwoiC5cDLDZMq7qaiQoQPRptxRPdephwxdlvzncgtRCkwnVLzZ6QMKp+CKr1YyMoBTx 6B82KALefCqS5ol8yScbhRT24pzjOZlWl3BXw= Received: by 10.229.128.74 with SMTP id j10mr1454794qcs.246.1304186457318; Sat, 30 Apr 2011 11:00:57 -0700 (PDT) References: <4DBC004C020000250003D099@gw.wicourts.gov> From: Joel Reymont In-Reply-To: <4DBC004C020000250003D099@gw.wicourts.gov> Mime-Version: 1.0 (iPhone Mail 8H7) Date: Sat, 30 Apr 2011 18:58:50 +0100 Message-ID: <4881277622113933088@unknownmsgid> Subject: Re: stored proc and inserting hundreds of thousands of rows To: Kevin Grittner 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=-0.345 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201104/437 X-Sequence-Number: 43499 Calculating distance involves giving an array of 150 float8 to a pgsql function, then calling a C function 2 million times (at the moment), giving it two arrays of 150 float8. Just calculating distance for 2 million rows and extracting the distance takes less than a second. I think that includes sorting by distance and sending 100 rows to the client. Are you suggesting eliminating the physical linking and calculating matching documents on the fly? Is there a way to speed up my C function by giving it all the float arrays, calling it once and having it return a set of matches? Would this be faster than calling it from a select, once for each array? Sent from my comfortable recliner On 30/04/2011, at 18:28, Kevin Grittner wrote: > Joel Reymont wrote: > >> We have 2 million documents now and linking an ad to all of them >> takes 5 minutes on my top-of-the-line SSD MacBook Pro. > > How long does it take to run just the SELECT part of the INSERT by > itself? > > -Kevin