5

Is there any fast way to get the number of rows in a dataset?

The best idea I can come up with is to do binary probing using $limit and $offset, or maybe some hybrid of binary probing and a final fetch of a single column within a $limit/$offset window when the size is known within, say, 100 or so.

(I checked the HTTP headers... no joy.)

Ed Staub
  • 15,480
  • 3
  • 61
  • 91

1 Answers1

7

One way you can achieve this is by doing a COUNT(*) operation on the dataset. For example, to get the total row count of this Socrata dataset:
https://data.seattle.gov/City-Business/Sold-Fleet-Equipment/y6ef-jf2w

You could issue this SODA query:
https://data.seattle.gov/resource/y6ef-jf2w.json?$select=count(*)

Adrian Laurenzi
  • 286
  • 1
  • 6
  • Thanks much! You might consider adding something to the docs (http://dev.socrata.com/docs/queries.html) to note that the aggregate functions default to the entire dataset if no $group is selected. – Ed Staub Jan 09 '15 at 15:15
  • This recently became case sensitive... so COUNT will not currently work. – geneorama Apr 26 '16 at 16:16