Skip to content

Commit

Permalink
Allow sorting on numerical columns
Browse files Browse the repository at this point in the history
- New column "numerical_props" which is populated by numerical properies
  and which is used exlusively for ordering.
  • Loading branch information
dantleech committed Jan 5, 2015
1 parent 93de594 commit 5dbd7f2
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testDefaultQuery()
$this->nodeTypeManager->expects($this->once())->method('getSubtypes')->will($this->returnValue( array() ));

$query = $this->factory->createQuery($this->factory->selector('nt:unstructured', 'nt:unstructured'), null, array(), array());
list($selectors, $selectorAliases, $sql) = $this->walker->walkQOMQuery($query);
list($telectors, $selectorAliases, $sql) = $this->walker->walkQOMQuery($query);

$this->assertEquals(sprintf("SELECT %s FROM phpcr_nodes n0 WHERE n0.workspace_name = ? AND n0.type IN ('nt:unstructured')", $this->defaultColumns), $sql);
}
Expand Down
8 changes: 8 additions & 0 deletions tests/benchmark.back/queries.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT \\* FROM [nt:unstructured];
SELECT \\* FROM [nt:unstructured] ORDER BY [i18n:de-title];
SELECT \\* FROM [nt:unstructured] AS a WHERE i18n:de-title IS NOT NULL ORDER BY [i18n:de-title];
SELECT \\* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') AND i18n:de-title IS NOT NULL ORDER BY [sulu:order], [i18n:de-title] DESC;
SELECT \\* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service');
SELECT \\* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') ORDER BY [i18n:de-title];
SELECT \\* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') AND i18n:de-title IS NOT NULL ORDER BY [i18n:de-title];
SELECT \\* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') AND i18n:de-title IS NOT NULL ORDER BY [sulu:order], [i18n:de-title] DESC;
19 changes: 19 additions & 0 deletions tests/benchmark.back/query_order_by.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

TARGET=$1

if [ -e $TARGET ]; then
rm $TARGET;
touch $TARGET;
fi

while read QUERY; do
echo $QUERY
echo $QUERY >> $TARGET;
for i in 1 2 3; do
echo "."
php ~/www/phpcr/phpcr-shell/bin/phpcrsh -psulucmf --command="$QUERY" | tail -n 1 >> $TARGET
done
done < queries.txt

cat $TARGET
32 changes: 32 additions & 0 deletions tests/benchmark.back/resmaster.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
SELECT \* FROM [nt:unstructured];
2143 rows in set (1.85349 sec)
2143 rows in set (1.84206 sec)
2143 rows in set (1.84249 sec)
SELECT \* FROM [nt:unstructured] ORDER BY [i18n:de-title];
2143 rows in set (1.99286 sec)
2143 rows in set (1.99348 sec)
2143 rows in set (1.97168 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE i18n:de-title IS NOT NULL ORDER BY [i18n:de-title];
330 rows in set (1.61598 sec)
330 rows in set (1.71619 sec)
330 rows in set (1.67897 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') AND i18n:de-title IS NOT NULL ORDER BY [sulu:order], [i18n:de-title] DESC;
57 rows in set (0.56263 sec)
57 rows in set (0.57022 sec)
57 rows in set (0.57564 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service');
57 rows in set (0.49192 sec)
57 rows in set (0.48148 sec)
57 rows in set (0.48259 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') ORDER BY [i18n:de-title];
57 rows in set (0.51039 sec)
57 rows in set (0.52756 sec)
57 rows in set (0.53138 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') AND i18n:de-title IS NOT NULL ORDER BY [i18n:de-title];
57 rows in set (0.53312 sec)
57 rows in set (0.56196 sec)
57 rows in set (0.54788 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') AND i18n:de-title IS NOT NULL ORDER BY [sulu:order], [i18n:de-title] DESC;
57 rows in set (0.56275 sec)
57 rows in set (0.56514 sec)
57 rows in set (0.57182 sec)
32 changes: 32 additions & 0 deletions tests/benchmark.back/resnumerical.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
SELECT \* FROM [nt:unstructured];
2143 rows in set (1.84274 sec)
2143 rows in set (1.94709 sec)
2143 rows in set (1.86058 sec)
SELECT \* FROM [nt:unstructured] ORDER BY [i18n:de-title];
2143 rows in set (2.04875 sec)
2143 rows in set (2.04055 sec)
2143 rows in set (2.00308 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE i18n:de-title IS NOT NULL ORDER BY [i18n:de-title];
330 rows in set (1.63383 sec)
330 rows in set (1.63438 sec)
330 rows in set (1.63745 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') AND i18n:de-title IS NOT NULL ORDER BY [sulu:order], [i18n:de-title] DESC;
57 rows in set (0.57677 sec)
57 rows in set (0.60930 sec)
57 rows in set (0.58204 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service');
57 rows in set (0.48024 sec)
57 rows in set (0.47330 sec)
57 rows in set (0.48214 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') ORDER BY [i18n:de-title];
57 rows in set (0.52143 sec)
57 rows in set (0.52957 sec)
57 rows in set (0.52393 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') AND i18n:de-title IS NOT NULL ORDER BY [i18n:de-title];
57 rows in set (0.54349 sec)
57 rows in set (0.55270 sec)
57 rows in set (0.54978 sec)
SELECT \* FROM [nt:unstructured] AS a WHERE ISDESCENDANTNODE(a, '/cmf/stanton/contents/service') AND i18n:de-title IS NOT NULL ORDER BY [sulu:order], [i18n:de-title] DESC;
57 rows in set (0.56815 sec)
57 rows in set (0.58603 sec)
57 rows in set (0.55674 sec)

0 comments on commit 5dbd7f2

Please sign in to comment.