Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 07FEC1337B93 for ; Tue, 29 Mar 2011 13:52:05 -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 57625-03 for ; Tue, 29 Mar 2011 16:51:57 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from cdptpa-omtalb.mail.rr.com (cdptpa-omtalb.mail.rr.com [75.180.132.123]) by mail.postgresql.org (Postfix) with ESMTP id 85E741337BB7 for ; Tue, 29 Mar 2011 13:51:57 -0300 (ADT) X-Authority-Analysis: v=1.1 cv=r4yJ8ACLDmU9N8MfnU6qGSvboKzSN9UnPAeXToqJDNE= c=1 sm=0 a=YOqqrsh--ucA:10 a=r6Jiw2x_onsA:10 a=8nJEP1OIZ-IA:10 a=qCTYjJJ2g1SgQhsHZAUATw==:17 a=oYZMiAjE7Ods0IdXa1MA:9 a=KxfJEybeSvD3fsaYOsMA:7 a=FIUuaVk_In_6XzoHzP_PsAIWBCEA:4 a=wPNLvfGTeEIA:10 a=UvA89RsQ9BjyT1jR:21 a=phsvAHy9l1VyBep8:21 a=qCTYjJJ2g1SgQhsHZAUATw==:117 X-Cloudmark-Score: 0 X-Originating-IP: 98.27.48.207 Received: from [98.27.48.207] ([98.27.48.207:39735] helo=[192.168.10.104]) by cdptpa-oedge01.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id A3/30-09483-B2E029D4; Tue, 29 Mar 2011 16:51:57 +0000 Message-ID: <4D920E29.2030706@dunslane.net> Date: Tue, 29 Mar 2011 12:51:53 -0400 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc13 Lightning/1.0b3pre Thunderbird/3.1.7 MIME-Version: 1.0 To: Guillaume Lelarge CC: Zheng Yang , Shiv , Selena Deckelmann , Alvaro Herrera , pgsql-students Subject: Re: foreign data wrappers References: <690867AB-C50B-4354-91D0-8A0811639C4C@gmail.com> <4D879CD0.5030803@dunslane.net> <3EF9E4CC-CF42-4B45-86FF-4CB9D46D7442@gmail.com> <4D8AF8C2.3000007@lelarge.info> <4ACC318A-1B6F-49A5-9B02-49EEAF7B97C7@gmail.com> <1300985156-sup-3058@alvh.no-ip.org> <47676.208.91.122.102.1300985713.squirrel@dunslane.net> <603812A0-F464-44AE-8A90-DF9BD1DC2DB9@gmail.com> <4D8E0125.9060905@dunslane.net> <8DB4D3E9-DA21-45FD-A2A2-5C6D479AA565@gmail.com> <4D91FF65.2090401@lelarge.info> <4D92098D.6040409@dunslane.net> <4D920A3D.8010004@lelarge.info> In-Reply-To: <4D920A3D.8010004@lelarge.info> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201103/41 X-Sequence-Number: 182 On 03/29/2011 12:35 PM, Guillaume Lelarge wrote: > Le 29/03/2011 18:32, Andrew Dunstan a écrit : >> >> On 03/29/2011 11:48 AM, Guillaume Lelarge wrote: >>> Le 29/03/2011 13:28, Zheng Yang a écrit : >>>> Hi guys, >>>> >>>>>> I've briefly gone through the slides. Regarding the 6 callbacks, is >>>>>> that correct to say that a full table scan will always be performed >>>>>> irregardless of the sql statement, >>>>>> the FDW is blind to the sql query performed, right? >>>>> Yes, fairly much. If the feed is large you need some way to pass a >>>>> limit to the foreign side, possibly via table options. I'm fairly >>>>> sure you won't be able to get it via the SELECT statement. >>>>> >>>> Regarding the previous flickr example, I'm wondering how this 'free >>>> text search' function can be done if the FDW is blind to the SELECT >>>> statement. >>>> >>>> For instance, the following query is to retrieve a photo relevant to >>>> 'panda': >>>> >>>> SELECT photo FROM flickr_table WHERE search LIKE '%panda%'; >>>> >>>> In this case, the FDW can only open a connection to flickr web >>>> service and return the next 'row' . >>>> The problem is that there are a huge number of photos in flickr >>>> server and retrieving them sequentially is not realistic. >>>> Any ideas on how this can be done? >>>> >>> It probably means that flickr is not a good example of a nice fdw. >> >> Neither of you are being very creative. As I mentioned above, you need >> to embed this sort of stuff in table options. >> >> so you would have something like: >> >> create foreign table panda_flickr (photo bytea, ...) >> server flickr_server >> options (searchterm 'panda', maxrows '50'); >> select photo from panda_flickr; >> > This would work but means you need to create a new foreign table to > search something else. > > So, yeah, it works, but it's not convenient. The other possibility is that you can dig down into the ForiegnScanState object. The FDW routines are passed a ForeignScanState object which contains a ScanState object which in turn contains a PlanState object which has a list of quals. You probably need to dig quite a bit further but that's a start. cheers andrew