diff options
author | rowanbeentje <rowan@beent.je> | 2010-01-02 01:52:38 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-01-02 01:52:38 +0000 |
commit | e42f000e98e9ff33a91a86a3e2a0cf04c6778102 (patch) | |
tree | ab52b693e5fe7122e10536b626f18b1a48399794 /Source | |
parent | 7753ee58924ee3d8da9177a1c318a28dd0bcd6d9 (diff) | |
download | sequelpro-e42f000e98e9ff33a91a86a3e2a0cf04c6778102.tar.gz sequelpro-e42f000e98e9ff33a91a86a3e2a0cf04c6778102.tar.bz2 sequelpro-e42f000e98e9ff33a91a86a3e2a0cf04c6778102.zip |
- With the improved row count support and behaviour, replace the old "Fetch correct row count" preference with a new Table row counts query level (never, only for small tables, always), defaulting to only for small tables - boundary currently set to 5MB. This addresses Issue #500
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConstants.h | 10 | ||||
-rw-r--r-- | Source/SPConstants.m | 3 | ||||
-rw-r--r-- | Source/SPPreferenceController.m | 7 | ||||
-rw-r--r-- | Source/TableContent.m | 6 |
4 files changed, 22 insertions, 4 deletions
diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 73f363c8..a4f844d4 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -48,6 +48,13 @@ typedef enum { SPSSHTunnelConnection = 2 } SPConnectionType; +// Table row count query usage levels +typedef enum { + SPRowCountFetchNever = 0, + SPRowCountFetchIfCheap = 1, + SPRowCountFetchAlways = 2 +} SPRowCountQueryUsageLevels; + // Kill mode constants extern NSString *SPKillProcessQueryMode; extern NSString *SPKillProcessConnectionMode; @@ -83,7 +90,8 @@ extern NSString *SPReloadAfterAddingRow; extern NSString *SPReloadAfterEditingRow; extern NSString *SPReloadAfterRemovingRow; extern NSString *SPLoadBlobsAsNeeded; -extern NSString *SPFetchCorrectRowCount; +extern NSString *SPTableRowCountQueryLevel; +extern NSString *SPTableRowCountCheapSizeBoundary; extern NSString *SPNewFieldsAllowNulls; extern NSString *SPLimitResults; extern NSString *SPLimitResultsValue; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 27fa998e..f5f6e5bf 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -58,7 +58,8 @@ NSString *SPReloadAfterAddingRow = @"ReloadAfterAddingRow"; NSString *SPReloadAfterEditingRow = @"ReloadAfterEditingRow"; NSString *SPReloadAfterRemovingRow = @"ReloadAfterRemovingRow"; NSString *SPLoadBlobsAsNeeded = @"LoadBlobsAsNeeded"; -NSString *SPFetchCorrectRowCount = @"FetchCorrectRowCount"; +NSString *SPTableRowCountQueryLevel = @"TableRowCountQueryLevel"; +NSString *SPTableRowCountCheapSizeBoundary = @"TableRowCountCheapLookupSizeBoundary"; NSString *SPNewFieldsAllowNulls = @"NewFieldsAllowNulls"; NSString *SPLimitResults = @"LimitResults"; NSString *SPLimitResultsValue = @"LimitResultsValue"; diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index 5d2f7575..1a2fdf41 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -166,7 +166,7 @@ @"reloadAfterEditing", SPReloadAfterEditingRow, @"reloadAfterRemoving", SPReloadAfterRemovingRow, @"dontShowBlob", SPLoadBlobsAsNeeded, - @"fetchRowCount", SPFetchCorrectRowCount, + @"fetchRowCount", @"FetchCorrectRowCount", @"limitRows", SPLimitResults, @"limitRowsValue", SPLimitResultsValue, @"nullValue", SPNullValue, @@ -288,6 +288,11 @@ [prefs setObject:queryFavoritesArray forKey:SPQueryFavorites]; } + // For versions prior to r1636 (<0.9.8), remove the old "Fetch correct row count" pref + if (recordedVersionNumber < 1636 && [prefs objectForKey:@"FetchCorrectRowCount"]) { + [prefs removeObjectForKey:@"FetchCorrectRowCount"]; + } + // Update the prefs revision [prefs setObject:[NSNumber numberWithInt:currentVersionNumber] forKey:SPLastUsedVersion]; } diff --git a/Source/TableContent.m b/Source/TableContent.m index cd780f5e..4cc301c2 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -2482,7 +2482,11 @@ checkStatusCount = YES; // Choose whether to display an estimate, or to fetch the correct row count, based on prefs - } else if ([prefs boolForKey:SPFetchCorrectRowCount]) { + } else if ([[prefs objectForKey:SPTableRowCountQueryLevel] intValue] == SPRowCountFetchAlways + || ([[prefs objectForKey:SPTableRowCountQueryLevel] intValue] == SPRowCountFetchIfCheap + && [tableDataInstance statusValueForKey:@"Data_length"] + && [[prefs objectForKey:SPTableRowCountCheapSizeBoundary] intValue] > [[tableDataInstance statusValueForKey:@"Data_length"] intValue])) + { maxNumRows = [self fetchNumberOfRows]; maxNumRowsIsEstimate = NO; [tableDataInstance setStatusValue:[NSString stringWithFormat:@"%d", maxNumRows] forKey:@"Rows"]; |