For sync purposes, I am trying to get a subset of the existing objects in a table.
The table has two fields, [Group]
and Member
, which are both stringified Guids.
All rows together may be to large to fit into a datatable; I already encountered an OutOfMemory
exception. But I have to check that everything I need right now is in the datatable. So I take the Guids I want to check (they come in chunks of 1000), and query only for the related objects.
So, instead of filling my datatable once with all
SELECT * FROM Group_Membership
I am running the following SQL query against my SQL database to get related objects for one thousand Guids at a time:
SELECT *
FROM Group_Membership
WHERE
[Group] IN (@Guid0, @Guid1, @Guid2, @Guid3, @Guid4, @Guid5, ..., @Guid999)
The table in question now contains a total of 142 entries, and the query already times out (CommandTimeout
= 30 seconds). On other tables, which are not as sparsely populated, similar queries don't time out.
Could someone shed some light on the logic of SQL Server and whether/how I could hint it into the right direction?
I already tried to add a nonclustered index on the column Group
, but it didn't help.