From e42f000e98e9ff33a91a86a3e2a0cf04c6778102 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 2 Jan 2010 01:52:38 +0000 Subject: - 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 --- Interfaces/English.lproj/Preferences.xib | 387 +++++++++++++++++++++---------- Resources/PreferenceDefaults.plist | 6 +- Source/SPConstants.h | 10 +- Source/SPConstants.m | 3 +- Source/SPPreferenceController.m | 7 +- Source/TableContent.m | 6 +- 6 files changed, 289 insertions(+), 130 deletions(-) diff --git a/Interfaces/English.lproj/Preferences.xib b/Interfaces/English.lproj/Preferences.xib index bbdb122f..c4f0892d 100644 --- a/Interfaces/English.lproj/Preferences.xib +++ b/Interfaces/English.lproj/Preferences.xib @@ -49,11 +49,9 @@ {1.79769e+308, 1.79769e+308} {500, 0} - + 256 {500, 172} - - {{0, 0}, {1920, 1178}} {500, 22} @@ -910,10 +908,117 @@ 268 YES + + + 268 + {{160, 16}, {322, 26}} + + YES + + -2076049856 + 2048 + + + 109199615 + 129 + + + 400 + 75 + + + Only use additional queries for small tables + + 1048576 + 2147483647 + 1 + + + _popUpItemAction: + 1 + + + YES + + OtherViews + + YES + + + Never use additional queries for table row counts + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + + Always get accurate row counts (slow for InnoDB) + + 1048576 + 2147483647 + + + _popUpItemAction: + 2 + + + + + + 1 + 1 + YES + YES + 2 + + + + + 268 + {{17, 22}, {140, 17}} + + YES + + 68288064 + 71304192 + Table row counts: + + + + + + + + + 12 + {{163, 46}, {316, 5}} + + {0, 0} + + 67239424 + 0 + Box + + + + 3 + MCAwLjgwMDAwMDAxMTkAA + + + 3 + 2 + 0 + NO + 268 - {{161, 181}, {123, 18}} + {{161, 198}, {123, 18}} YES @@ -935,7 +1040,7 @@ 268 - {{32, 220}, {125, 17}} + {{32, 237}, {125, 17}} YES @@ -951,7 +1056,7 @@ 268 - {{383, 67}, {38, 17}} + {{383, 104}, {38, 17}} YES @@ -967,7 +1072,7 @@ 268 - {{161, 221}, {106, 18}} + {{161, 238}, {106, 18}} YES @@ -989,7 +1094,7 @@ 268 - {{161, 66}, {115, 18}} + {{161, 103}, {115, 18}} YES @@ -1011,7 +1116,7 @@ 268 - {{161, 201}, {105, 18}} + {{161, 218}, {105, 18}} YES @@ -1033,7 +1138,7 @@ 268 - {{362, 61}, {19, 27}} + {{362, 98}, {19, 27}} YES @@ -1051,7 +1156,7 @@ 268 - {{282, 64}, {75, 22}} + {{282, 101}, {75, 22}} YES @@ -1088,7 +1193,7 @@ #,##1 - #,##0 + #,##1 @@ -1121,7 +1226,7 @@ 268 - {{17, 22}, {140, 17}} + {{17, 59}, {140, 17}} YES @@ -1137,7 +1242,7 @@ 268 - {{163, 20}, {75, 22}} + {{163, 57}, {75, 22}} YES @@ -1155,7 +1260,7 @@ 268 - {{161, 141}, {297, 18}} + {{161, 158}, {297, 18}} YES @@ -1174,32 +1279,10 @@ 25 - - - 268 - {{161, 121}, {225, 18}} - - YES - - 67239424 - 0 - Fetch correct row count (slower) - - - 1211912703 - 2 - - - - - 200 - 25 - - 12 - {{163, 167}, {316, 5}} + {{163, 184}, {316, 5}} {0, 0} @@ -1221,7 +1304,7 @@ 12 - {{163, 92}, {316, 5}} + {{163, 129}, {316, 5}} {0, 0} @@ -1243,7 +1326,7 @@ 12 - {{163, 53}, {316, 5}} + {{163, 90}, {316, 5}} {0, 0} @@ -1265,7 +1348,7 @@ 268 - {{161, 101}, {206, 18}} + {{161, 138}, {206, 18}} YES @@ -1285,7 +1368,7 @@ - {500, 259} + {499, 276} NSView @@ -2920,7 +3003,7 @@ AQAAAAA NSView - + 268 YES @@ -2936,7 +3019,6 @@ AQAAAAA {{154, 199}, {44, 23}} - YES YES @@ -2956,7 +3038,6 @@ AQAAAAA {{154, 228}, {44, 23}} - YES YES @@ -2976,7 +3057,6 @@ AQAAAAA {{154, 141}, {44, 23}} - YES YES @@ -2996,7 +3076,6 @@ AQAAAAA {{154, 112}, {44, 23}} - YES YES @@ -3016,7 +3095,6 @@ AQAAAAA {{154, 286}, {44, 23}} - YES YES @@ -3036,7 +3114,6 @@ AQAAAAA {{154, 170}, {44, 23}} - YES YES @@ -3056,7 +3133,6 @@ AQAAAAA {{154, 83}, {44, 23}} - YES YES @@ -3076,7 +3152,6 @@ AQAAAAA {{154, 54}, {44, 23}} - YES YES @@ -3096,7 +3171,6 @@ AQAAAAA {{154, 315}, {44, 23}} - YES YES @@ -3116,7 +3190,6 @@ AQAAAAA {{154, 257}, {44, 23}} - YES 1 @@ -3128,7 +3201,6 @@ AQAAAAA 268 {{86, 202}, {63, 17}} - YES 68288064 @@ -3145,7 +3217,6 @@ AQAAAAA 268 {{88, 173}, {61, 17}} - YES 68288064 @@ -3162,7 +3233,6 @@ AQAAAAA 268 {{79, 231}, {70, 17}} - YES 68288064 @@ -3179,7 +3249,6 @@ AQAAAAA 268 {{89, 86}, {60, 17}} - YES 68288064 @@ -3196,7 +3265,6 @@ AQAAAAA 268 {{23, 58}, {125, 17}} - YES 68288064 @@ -3213,7 +3281,6 @@ AQAAAAA 268 {{102, 144}, {47, 17}} - YES 68288064 @@ -3230,7 +3297,6 @@ AQAAAAA 268 {{112, 318}, {37, 17}} - YES 68288064 @@ -3247,7 +3313,6 @@ AQAAAAA 268 {{46, 115}, {103, 17}} - YES 68288064 @@ -3264,7 +3329,6 @@ AQAAAAA 268 {{66, 289}, {83, 17}} - YES 68288064 @@ -3281,7 +3345,6 @@ AQAAAAA 268 {{113, 357}, {36, 17}} - YES 68288064 @@ -3298,7 +3361,6 @@ AQAAAAA 268 {{73, 12}, {131, 32}} - YES -2080244224 @@ -3319,7 +3381,6 @@ AQAAAAA 268 {{396, 347}, {90, 32}} - YES 67239424 @@ -3340,7 +3401,6 @@ AQAAAAA 268 {{154, 355}, {240, 19}} - YES -2076049856 @@ -3358,7 +3418,6 @@ AQAAAAA 268 {{107, 260}, {42, 17}} - YES 605158976 @@ -3375,7 +3434,6 @@ AQAAAAA 268 {{257, 317}, {126, 18}} - YES -2080244224 @@ -3398,7 +3456,6 @@ AQAAAAA 268 {{257, 288}, {150, 18}} - YES -2080244224 @@ -3421,7 +3478,6 @@ AQAAAAA 268 {{257, 230}, {179, 18}} - YES 67239424 @@ -3444,7 +3500,6 @@ AQAAAAA 268 {{257, 259}, {185, 18}} - YES -2080244224 @@ -3467,7 +3522,6 @@ AQAAAAA 268 {{257, 173}, {185, 18}} - YES -2080244224 @@ -3490,7 +3544,6 @@ AQAAAAA -2147483380 {{257, 144}, {197, 18}} - YES -1543373312 @@ -3513,7 +3566,6 @@ AQAAAAA 268 {{357, 205}, {29, 19}} - YES -1538130368 @@ -3587,7 +3639,6 @@ AQAAAAA 268 {{298, 207}, {54, 14}} - YES 605158976 @@ -3604,7 +3655,6 @@ AQAAAAA 268 {{392, 203}, {15, 22}} - YES 604896800 @@ -3623,7 +3673,6 @@ AQAAAAA 268 {{410, 207}, {27, 14}} - YES 605158976 @@ -3640,7 +3689,6 @@ AQAAAAA 12 {{154, 344}, {326, 5}} - {0, 0} 67239424 @@ -3660,11 +3708,13 @@ AQAAAAA {500, 395} - - NSView + + YES + TableRowCountQueryLevel + YES @@ -3686,6 +3736,7 @@ AQAAAAA DisplayTableViewVerticalGridlines type + TableRowCountQueryLevel YES YES @@ -3845,22 +3896,6 @@ AQAAAAA 614 - - - value: values.FetchCorrectRowCount - - - - - - value: values.FetchCorrectRowCount - value - values.FetchCorrectRowCount - 2 - - - 615 - value: values.ReloadAfterRemovingRow @@ -5742,6 +5777,22 @@ AQAAAAA 1464 + + + selectedTag: values.TableRowCountQueryLevel + + + + + + selectedTag: values.TableRowCountQueryLevel + selectedTag + values.TableRowCountQueryLevel + 2 + + + 1484 + @@ -6281,22 +6332,24 @@ AQAAAAA YES - - - - - - - - + + + + + + + + + + Tables @@ -6464,20 +6517,6 @@ AQAAAAA - - 544 - - - YES - - - - - - 545 - - - 552 @@ -8124,6 +8163,69 @@ AQAAAAA + + 1467 + + + + + 1468 + + + YES + + + + + + 1469 + + + + + 1470 + + + YES + + + + + + 1471 + + + YES + + + + + + 1472 + + + YES + + + + + + + + 1473 + + + + + 1474 + + + + + 1475 + + + @@ -8316,6 +8418,16 @@ AQAAAAA 1465.IBPluginDependency 1465.ImportedFromIB2 1466.IBPluginDependency + 1467.IBPluginDependency + 1468.IBPluginDependency + 1469.IBPluginDependency + 1470.IBPluginDependency + 1471.IBPluginDependency + 1472.IBEditorWindowLastContentRect + 1472.IBPluginDependency + 1473.IBPluginDependency + 1474.IBPluginDependency + 1475.IBPluginDependency 17.IBEditorWindowLastContentRect 17.IBPluginDependency 17.IBUserGuides @@ -8495,8 +8607,6 @@ AQAAAAA 534.IBPluginDependency 535.IBPluginDependency 538.IBPluginDependency - 544.IBPluginDependency - 545.IBPluginDependency 552.IBPluginDependency 553.IBPluginDependency 554.IBPluginDependency @@ -8772,6 +8882,16 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{467, 116}, {401, 63}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{571, 222}, {500, 280}} com.apple.InterfaceBuilder.CocoaPlugin @@ -8952,7 +9072,7 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin - {{318, 154}, {500, 259}} + {{318, 137}, {499, 276}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -8989,8 +9109,6 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin {{254, 472}, {500, 209}} com.apple.InterfaceBuilder.CocoaPlugin @@ -9157,7 +9275,7 @@ AQAAAAA - 1466 + 1484 @@ -9428,6 +9546,13 @@ AQAAAAA AppKit.framework/Headers/NSUserInterfaceItemSearching.h + + NSApplication + + IBFrameworkSource + BWToolkitFramework.framework/Headers/NSApplication+BWAdditions.h + + NSArrayController NSObjectController @@ -10059,6 +10184,13 @@ AQAAAAA NSResponder + + NSView + + IBFrameworkSource + BWToolkitFramework.framework/Headers/NSView+BWAdditions.h + + NSWindow @@ -10081,6 +10213,13 @@ AQAAAAA AppKit.framework/Headers/NSWindowScripting.h + + NSWindow + + IBFrameworkSource + BWToolkitFramework.framework/Headers/NSWindow+BWAdditions.h + + NSWindowController NSResponder diff --git a/Resources/PreferenceDefaults.plist b/Resources/PreferenceDefaults.plist index 71e9473d..233569d2 100644 --- a/Resources/PreferenceDefaults.plist +++ b/Resources/PreferenceDefaults.plist @@ -20,8 +20,10 @@ LoadBlobsAsNeeded - FetchCorrectRowCount - + TableRowCountQueryLevel + 1 + TableRowCountCheapLookupSizeBoundary + 5242880 NewFieldsAllowNulls LimitResults 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"]; -- cgit v1.2.3