[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: SQL to get WORKING from NODES

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Fri, 24 Sep 2010 12:05:26 +0100

Philip Martin <philip.martin_at_wandisco.com> writes:

> but I don't know how to fix the second one. How do I count the number
> of rows returned by that GROUP BY query?

From IRC the following was suggested

-- STMT_SELECT_WORKING_NODE_CHILDREN_1
SELECT DISTINCT local_relpath FROM nodes
WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth > 0;

-- STMT_COUNT_WORKING_NODE_CHILDREN_1
SELECT COUNT(*) FROM (SELECT DISTINCT local_relpath FROM nodes
                      WHERE wc_id = ?1 AND parent_relpath = ?2
                      AND op_depth > 0);

In the longer term if/when we switch to per-dir queries we can
probably eliminate the counting step in some or all cases.

> This leads on to the problem of selecting just the highest op_depth
> for each child. Is it possible to get one query to return just the
> highest op_depth for each child?

I suspect we will still want to do this at some point.

-- 
Philip
Received on 2010-09-24 13:06:13 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.