After I get excellent results with converting data “to_timestamp” and “to_number” from VB.NET I am wondering if PostgreSQL have possibility to query table indexes by array of integers from .NET?
Say, I have array filled with (1, 3, 5, 6, 9).
Is here any possibility that PostgreSQL return rows with data from those indexes to “odbc.reader”?
That would be much faster than looping and querying 5 times like I do now.
Something like this:
SELECT myindexes, myname, myadress from mytable WHERE myindexes IS IN ARRAY
If this is possible how a simple query should look like?
That’s possible.
ANY
Example with integer-array:
Details about
ANYin the manual.IN
There is also the SQL
IN()expression for the same purpose.PostgreSQl in its current implementation transforms that to
= ANY (array)internally prior to execution, so it’s conceivably a bit slower.Examples for joining to a long list (as per comment):
JOIN to VALUES expression
I am using a CTE in the example (which is optional, could be a sub-query as well). You need PostgreSQL 8.4 of later for that.
The manual about
VALUES.JOIN to unnested array
Or you could
unnest()an array andJOINto it:Each of these methods is far superior in performance to running a separate query per value.