Skip to content

Commit

Permalink
Change query looking for the need to "reshape subscription" to
Browse files Browse the repository at this point in the history
return a count of nodes, rather than the list of nodes.

This is effectively a minor performance tweak.
  • Loading branch information
Christopher Browne committed Aug 18, 2010
1 parent ed9978d commit 18d9a81
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/slonik/slonik.c
Expand Up @@ -3445,7 +3445,7 @@ slonik_subscribe_set(SlonikStmt_subscribe_set * stmt)
SlonikAdmInfo *adminfo1;
SlonDString query;
PGresult *res1;
SlonikAdmInfo * adminfo2;
SlonikAdmInfo *adminfo2;
int reshape=0;

adminfo1 = get_active_adminfo((SlonikStmt *) stmt, stmt->sub_provider);
Expand All @@ -3461,11 +3461,10 @@ slonik_subscribe_set(SlonikStmt_subscribe_set * stmt)
* If the receiver is already subscribed to
* the set through a different provider
* slonik will need to tell the receiver
* about this change directy.
*
* about this change directly.
*/

slon_mkquery(&query,"select * FROM \"_%s\".sl_subscribe " \
slon_mkquery(&query,"select count(*) FROM \"_%s\".sl_subscribe " \
"where sub_set=%d AND sub_receiver=%d " \
" and sub_active=true and sub_provider<>%d",
stmt->hdr.script->clustername,
Expand All @@ -3477,7 +3476,7 @@ slonik_subscribe_set(SlonikStmt_subscribe_set * stmt)
dstring_free(&query);
return -1;
}
if(PQntuples(res1) > 0)
if (strtol(PQgetvalue(res1, 0, 0), NULL, 10) > 0)
{
reshape=1;
}
Expand Down

0 comments on commit 18d9a81

Please sign in to comment.