From 40f21c3917be1e9895498aa830721eb723cd04a4 Mon Sep 17 00:00:00 2001
From: Miroslav Stampar <miroslav.stampar@gmail.com>
Date: Wed, 23 Nov 2011 15:38:31 +0000
Subject: [PATCH] minor update

---
 lib/techniques/union/use.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/techniques/union/use.py b/lib/techniques/union/use.py
index 65964aa60..6319cc36b 100644
--- a/lib/techniques/union/use.py
+++ b/lib/techniques/union/use.py
@@ -163,6 +163,10 @@ def unionUse(expression, unpack=True, dump=False):
 
     _, _, _, _, _, expressionFieldsList, expressionFields, _ = agent.getFields(origExpr)
 
+    if expressionFieldsList and len(expressionFieldsList) > 1 and " ORDER BY " in expression:
+        # No need for it in and just slowing down on large table dumps
+        expression = expression[:expression.rindex(" ORDER BY ")]
+
     # We have to check if the SQL query might return multiple entries
     # and in such case forge the SQL limiting the query output one
     # entry per time