|
24 | 24 | from lib.core.common import isNumPosStrValue |
25 | 25 | from lib.core.common import listToStrValue |
26 | 26 | from lib.core.common import randomInt |
| 27 | +from lib.core.common import readInput |
27 | 28 | from lib.core.common import safeStringFormat |
28 | 29 | from lib.core.convert import htmlunescape |
29 | 30 | from lib.core.convert import safecharencode |
|
38 | 39 | from lib.core.settings import FROM_TABLE |
39 | 40 | from lib.core.settings import MYSQL_ERROR_CHUNK_LENGTH |
40 | 41 | from lib.core.settings import MSSQL_ERROR_CHUNK_LENGTH |
| 42 | +from lib.core.settings import SLOW_ORDER_COUNT_THRESHOLD |
41 | 43 | from lib.core.settings import SQL_SCALAR_REGEX |
42 | 44 | from lib.core.settings import TURN_OFF_RESUME_INFO_LIMIT |
43 | 45 | from lib.core.threads import getCurrentThreadData |
@@ -292,9 +294,8 @@ def errorUse(expression, expected=None, resumeValue=True, dump=False): |
292 | 294 | # Count the number of SQL query entries output |
293 | 295 | countedExpression = expression.replace(expressionFields, queries[Backend.getIdentifiedDbms()].count.query % '*', 1) |
294 | 296 |
|
295 | | - if re.search(" ORDER BY ", expression, re.I): |
296 | | - untilOrderChar = countedExpression.index(" ORDER BY ") |
297 | | - countedExpression = countedExpression[:untilOrderChar] |
| 297 | + if " ORDER BY " in expression: |
| 298 | + countedExpression = countedExpression[:countedExpression.index(" ORDER BY ")] |
298 | 299 |
|
299 | 300 | count = resume(countedExpression, None) |
300 | 301 |
|
@@ -328,6 +329,14 @@ def errorUse(expression, expected=None, resumeValue=True, dump=False): |
328 | 329 |
|
329 | 330 | return outputs |
330 | 331 |
|
| 332 | + if " ORDER BY " in expression and (stopLimit - startLimit) > SLOW_ORDER_COUNT_THRESHOLD: |
| 333 | + message = "due to huge table size do you want to remove " |
| 334 | + message += "ORDER BY clause gaining speed over consistency? [y/N] " |
| 335 | + output = readInput(message, default="N") |
| 336 | + |
| 337 | + if output and output[0] in ("y", "Y"): |
| 338 | + expression = expression[:expression.index(" ORDER BY ")] |
| 339 | + |
331 | 340 | threadData = getCurrentThreadData() |
332 | 341 | threadData.shared.limits = iter(xrange(startLimit, stopLimit)) |
333 | 342 | numThreads = min(conf.threads, (stopLimit - startLimit)) |
|
0 commit comments