Udostępnij za pośrednictwem


JetGetObjectInfo() does not get record count by default

We recently had the following question:


 I am trying to get the space occupied by each table that we have by using JetGetObjectInfo. The api succeeds but it returns 0 for both number of cRecords and cPages.

 

 

JET_OBJECTINFO tableInfo = {0};  hr = ::JetGetObjectInfoA(m_spSession->GetSessionId(), m_dbId, JET_objtypTable, nullptr, strTableName, &tableInfo, sizeof(tableInfo), JET_ObjInfo);  if (FAILED(hr)) return hr; 

JetGetTableInfo didnt help as well.

 

However if i open the cursor and do a JetIndexRecordCount I see lots of records present in this table/index.

If i use JetGetIndexInfo on the clustered index I get the space occupied (using JET_IdxInfoSpaceAlloc) i get 80 as result (I beleive this is in pages).

 

Please let me know if i am missing some options that ought to be passed (grbits in the tableInfo ?).

 

Thanks,

 


It's not obvious, but you need to call JetComputeStats() first.

Calculating these numbers can be expensive to calculate on a large table, which is why the default behaviour is to leave them at zero.

Documentation on JetComputeStats() can be found at https://msdn.microsoft.com/en-us/library/windows/desktop/gg269192(v=exchg.10).aspx

.