Question about stats -> user attributes (in General)


AdminShade December 19 2005 6:38 AM EST

for say HP DX and ST, we now have some 270+ pages.

I looked for the first minion having 20 HP that was on the rankings of HP, total list being 276 pages, and saw that minion on page 189.

wouldn't it be faster for the server to only load non base, as in 20+, basic attributes, which are HP DX and ST)

in other words: why not have the system ignore rankings for 20 DX 20 HP and 20 ST and only count those that are higher to the rankings?

bartjan December 19 2005 7:05 AM EST

That actually is slower than it is right now.

select count(*) from minions;

is in most database engines faster than

select count(*) from minions where HP > 20;

AdminShade December 19 2005 7:08 AM EST

ok that makes sense.

But perhaps if not faster: wouldn't it make the display better.

ATM almost 1/4 of the frame is taken over by the list of pages, with that change that list would be quite smaller (almost 1/3 smaller) making more space for rankings listed per page, making the list of ranking pages even smaller.

Just an idea :)

Relic December 19 2005 9:36 AM EST

bartjan, query efficiency is due in large part to index optimization, so, if Jonathan had an index on the HP column in that table, it would actually be much faster and less intensive on the database because you would be pulling from an indexed subset of the table, rather than having to pull blocks from the entire table.

bartjan December 19 2005 11:15 AM EST

Mmm, isn't keeping track of the total number of records not also very convenient for various other things? So I assumed Postgresql would already have that number stored as a separate variable.
This way, in order to get the total number of records in a table, only 1 variable needs to be checked. If only records having HP>20 needs to be selected, it indeed only needs to check the index for HP, but that still is a very long list.

AdminJonathan December 19 2005 12:05 PM EST

Actually, because there is no one true number of rows available in a transactioned environment, postgresql doesn't special case count(*).

Consider, for example, two threads.

Thread 1:
BEGIN TRANSACTION;
INSERT INTO MINIONS ...;
[does not commit yet]
SELECT count(*) FROM MINIONS;

Thread 2
SELECT count(*) FROM MINIONS;

In isolation mode "read committed" (IIRC the ANSI default) and higher, thread 2's count should be one less than thread 1's.

bartjan December 19 2005 12:19 PM EST

Mmm, you're right. Well, that's what I get for choosing MySQL as the default database to use ;)

Bootsanator December 19 2005 12:25 PM EST

/me watches the big boys talk about their programming awesomeness and figures he should at least learn HTML one of these days so he knows Something behind-the-scenes in everything (even if it's basic simple shtuff)

AdminShade December 19 2005 12:28 PM EST

Hehehe, I know a bit of HTML now myself, but am still amazed at what they do O.0

Relic December 20 2005 12:04 AM EST

There are currently 5223 characters created on CB2, at 4 minions per character that is only 21Kish rows in the minions table. On any database worth its salt, that is a simple and extremely fast query. Now, once you get tables in Oracle for instance of 100 million+ rows, then you really have to worry about having your SQL code highly optimized. :P
This thread is closed to new posts. However, you are welcome to reference it from a new thread; link this with the html <a href="/bboard/q-and-a-fetch-msg.tcl?msg_id=001dp5">Question about stats -> user attributes</a>