William Grant has proposed merging lp:~wgrant/launchpad/faster-latest-things 
into lp:launchpad.

Commit message:
Let latest questions, specifications and products be efficiently calculated.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/faster-latest-things/+merge/306213

Let latest questions, specifications and products be efficiently calculated.

The DB patch will be applied hot.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~wgrant/launchpad/faster-latest-things into lp:launchpad.
=== added file 'database/schema/patch-2209-67-3.sql'
--- database/schema/patch-2209-67-3.sql	1970-01-01 00:00:00 +0000
+++ database/schema/patch-2209-67-3.sql	2016-09-20 13:00:12 +0000
@@ -0,0 +1,10 @@
+-- Copyright 2016 Canonical Ltd.  This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+SET client_min_messages=ERROR;
+
+CREATE INDEX question__datecreated__idx ON question(datecreated);
+CREATE INDEX specification__datecreated__id__idx ON specification(datecreated, id DESC);
+CREATE INDEX product__datecreated__id__idx ON product(datecreated, id DESC);
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 67, 3);

=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py	2016-09-20 02:35:57 +0000
+++ lib/lp/registry/model/product.py	2016-09-20 13:00:12 +0000
@@ -1812,7 +1812,7 @@
     def get_all_active(cls, user, eager_load=True):
         clause = cls.getProductPrivacyFilter(user)
         result = IStore(Product).find(Product, Product.active,
-                    clause).order_by(Desc(Product.datecreated))
+                    clause).order_by(Desc(Product.datecreated), Product.id)
         if not eager_load:
             return result
 
@@ -2021,10 +2021,8 @@
                 )
                 ''' % sqlvalues(tuple(licenses))))
 
-        result = IStore(Product).find(
-            Product, *conditions).config(
-                distinct=True).order_by(
-                    Product.datecreated, Product.display_name)
+        result = IStore(Product).find(Product, *conditions).order_by(
+            Product.datecreated, Desc(Product.id))
 
         def eager_load(products):
             return get_precached_products(

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to