Ticket #19 (closed enhancement: fixed)

Opened 7 years ago

Last modified 15 months ago

getCount() - a single method for counting records

Reported by: dartar Owned by: DotMG
Priority: high Milestone: 1.3.1
Component: core Version: 1.1.6.0
Severity: normal Keywords:
Cc:

Description

There are numerous places in Wikka where we need to know "how many" of a certain thing there are in the database: how many pages, how many comments, how many pages owned by the logged-in user, ... etc. And there will be more.

Currently all these counts are retrieved via different methods: sometimes building a query and getting the count directly (the most efficient way); sometimes by using the LoadSingle() method after building a query, which is highly inefficient, as it effectively first asks MySQL to assign a name to the count and return records in an associative array, then retrieves the first (only!) item from the array of records, and finally retrieves the number from the associative array by name.

A single method

To avoid all this inconsistency and inefficiency, here is a simple method that does nothing but retrieve a count and return it as an integer.

Status

tested

To do

All actions, handlers and core methods that used different kinds of query to count records should be modified to use this new method. Instructions are given on the source page.

Change History

Changed 7 years ago by dartar

  • priority changed from normal to high

Changed 5 years ago by DotMG

  • owner changed from dartar to DotMG
  • status changed from new to assigned

Changed 5 years ago by DotMG

  • milestone changed from 1.1.7.2 to 1.1.7

Changed 5 years ago by DotMG

  • status changed from assigned to closed
  • resolution set to fixed

(In [531]) fixes #19

ported code at  http://wikkawiki.org/WikkaCountingRecords

Applied the new method to CountAllComments() and CountComments().

Changed 5 years ago by DarTar

I suggest we wait closing this ticket, since there might be other places where it could be applied to improve performance. I remember for instance that the new referrer handlers (#1) use this method.

Changed 5 years ago by DotMG

I prefer letting tickets resolved as closed, and open new Wiki pages or a coordination ticket instead, and move all simple details or links there. But if it is more advantageous to reopen tickets for just details, further discussions (as in #498) or as remainder, I'd suggest to modify the title and add tags like [FIXED] or [NOTE] or [TALK], ... so as to show it clearly in the report that such ticket is OK, ... or almost.

Changed 3 years ago by DarTar

  • milestone changed from 1.2 to 1.3

Retargeting to 1.3, this ticket has already been closed in trunk, from which 1.3 will be branched. Consider backporting urgent issues to 1.2.X

Changed 15 months ago by BrianKoontz

  • milestone changed from 1.3 to 1.3.1

Updated milestone to 1.3.1

Note: See TracTickets for help on using tickets.