I am trying to attach a large table (18million rows) from SQL2008 to geoserver. When creating the new layer from within geoserver or reloading geoserver the following call is being run on SQL Server.
SELECT "geom".STSrid FROM "theTable" WHERE "geom" IS NOT NULL.
This loads 18 million rows to query the Srid.
I suggest that SQLServerDialect.java is updated to select just the 1 required row. In particular Line 155 which is in the getGeometrySRID function should be updated from:
StringBuffer sql = new StringBuffer("SELECT ");
StringBuffer sql = new StringBuffer("SELECT TOP 1 ");