How to get Count from ArcGisProQuery without loading all data

514
4
Jump to solution
08-16-2021 01:01 PM
SebastianKrings
Occasional Contributor

Hi,

we are working with ArcGisProQuery. I am wondering if there is a way to get just the count instead the full result. Its because we want do pretend the user from loading too much data and want to evaluate how many items would be loaded by a previously constructed query.

The query constructions may contain some where-clauses like a spatialfilter intersect or just some date-comparison.

Basically we are using the queries as follows:

ArcGisProQuery sdeQuery = [...];
var filter = sdeQuery.ToQuery(shapeFieldName, featureClass);
RowCursor cursor = featureClass.Search(filter);

 

I tried to change the given select-fields from the subfields-property by a hard coded "Count(*)" but I am getting an error about quota. Thats weird because loading the data including shape fields works fine.

Hopefully someone has an idea.
Thanks.

0 Kudos
1 Solution

Accepted Solutions
RichRuh
Esri Regular Contributor

Sebastian,

I haven't had time to test this, but have you tried creating a QueryTable?

You create a QueryTable using the Geodatabase.OpenQueryTable method. This routine takes a QueryTableDescription object, which is built around a QueryDef.  The routines returns a Table that you might be able to use with Table.CalculateStatistics.

--Rich

View solution in original post

0 Kudos
4 Replies
RichRuh
Esri Regular Contributor

I'm not familiar with ArcGisProQuery.

If you want to use the Pro SDK, I would take a look at Table.CalculateStatistics.  Here are some docs that walk through how to use this method.  For your example, you would set the TableStatistics.QueryFilter to the query, and then create a single StatisticsDescription that uses the Count as the StatisticsFunction.

I hope this helps,

--Rich

 

0 Kudos
SebastianKrings
Occasional Contributor

Thanks for the reply.
As far as I see you solution it only works on a single table (table.CalculateStatistics). Where on the StatisticsResult I could work with.

Our Queries, which are translated into a ArcGis QueryDef-object, may contain joins over multiple tables.
But I did not found something similar to "TableStatistics.QueryFilter" where I just could pass my join query.

I am wondering because in the UI of ArcGisPro you can also define queries, very similar to the programmatically way we are doin. And there it is possible to check an option "counts only". I would like to achieve that too.

0 Kudos
RichRuh
Esri Regular Contributor

Sebastian,

I haven't had time to test this, but have you tried creating a QueryTable?

You create a QueryTable using the Geodatabase.OpenQueryTable method. This routine takes a QueryTableDescription object, which is built around a QueryDef.  The routines returns a Table that you might be able to use with Table.CalculateStatistics.

--Rich

0 Kudos
SebastianKrings
Occasional Contributor

Thanks for the reply.

Unfortunately I cannot track this issue any more. I forwarded your information.
Due to that I mark your answer as solution.

0 Kudos