Comment On Yes, the Table is Still There

"Having recently upgraded my forum software," Kinta wrote, "I noticed that my site had been running incredibly slow." [expand full text]
« PrevPage 1 | Page 2Next »

Re: Yes, the Table is Still There

2008-07-16 08:02 • by fruey (unregistered)
It's only fetching the current item_id... not the whole table, unless I'm very much mistaken...

Re: Yes, the Table is Still There

2008-07-16 08:03 • by Kluge Doctor (unregistered)
With a computers, we can bring OCD to the next level!

Re: Yes, the Table is Still There

2008-07-16 08:05 • by Kluge Doctor (unregistered)
206184 in reply to 206182
fruey:
It's only fetching the current item_id... not the whole table, unless I'm very much mistaken...

It's the whole table of item_id, every record!

Re: Yes, the Table is Still There

2008-07-16 08:06 • by snoofle
Select $WTF
From Comments
Where TRWTF = 'Stupid Developer';

Re: Yes, the Table is Still There

2008-07-16 08:07 • by anon-e moose (unregistered)
better to be safe than sorry

Re: Yes, the Table is Still There

2008-07-16 08:16 • by taylonr
For a while I was playing an online (American) football sim. Rather than buying forum software (which they could have easily afforded) they decided to write their own. Their justification came down to about 7 different ways of saying "because we want to."

Anyway, one of the things they heard constantly was that their forums ran too slow. Turns out they were calculating # of posts on every page load. The turned off post count (instead of just fixing the bug) and forums sped up by several orders of magnitude.

Re: Yes, the Table is Still There

2008-07-16 08:20 • by gabba
So ... the real WTF is the forum software? That has never happened before.

Re: Yes, the Table is Still There

2008-07-16 08:25 • by PleegWat (unregistered)
Isn't TRWTF the forum software on THIS site?

Re: Yes, the Table is Still There

2008-07-16 08:26 • by dkf
They're allocating 100 characters for the item_id? What are they putting in there, the item's full name and postal address?

Re: Yes, the Table is Still There

2008-07-16 08:27 • by benza (unregistered)
206192 in reply to 206189
Too bad we don't have the full query, I'm pretty sure it does not even add the item_id and item_lang columns.

Re: Yes, the Table is Still There

2008-07-16 08:39 • by El Duderino
Brillant!

Re: Yes, the Table is Still There

2008-07-16 08:40 • by Arancaytar
206197 in reply to 206182
fruey:
It's only fetching the current item_id... not the whole table, unless I'm very much mistaken...


It executes an SQL query that would fetch all rows (no LIMIT). PHP probably fetches the resulting rows, and even if it doesn't, the poor database server has its work cut out.

Re: Yes, the Table is Still There

2008-07-16 08:50 • by Mike (unregistered)
And here I thought that the WTF was the "item cache" which is slower than what it's intended to cache...

Re: Yes, the Table is Still There

2008-07-16 08:54 • by D2oris (unregistered)
206204 in reply to 206188
gabba:
So ... the real WTF is the forum software? That has never happened before.


Win.

Re: Yes, the Table is Still There

2008-07-16 09:07 • by blah (unregistered)
This code reminds me of a certain interview WTF.

"The alter statements lead you to run the CREATE TABLE query, but there is no CREATE TABLE in SQL. What do you do?"

Re: Yes, the Table is Still There

2008-07-16 09:11 • by Thomas P (unregistered)
206209 in reply to 206188
Google code search gives the answer:

http://anotherraid.googlecode.com/svn/trunk/ar/itemstats/includes/itemcache.php

The software home page:
http://code.google.com/p/anotherraid/
A World of Warcraft raid tracking, planning and in the future dkp-point system.

Re: Yes, the Table is Still There

2008-07-16 09:12 • by dpm
206210 in reply to 206187
taylonr:
The turned off post count (instead of just fixing the bug) and forums sped up by several orders of magnitude.

That is quite impressive. Let's say it now takes one second to load a page. Before they disabled the count, it was taking one thousand seconds (three orders of magnitude), which is sixteen minutes and forty seconds. I admire your patience to wait that long for a single page!

Re: Yes, the Table is Still There

2008-07-16 09:14 • by ParkinT
What could have possibly been the intention of the developer who wrote this?
After the first time it runs, the table is there. End of story!

It would have been more efficient to simply catch a database error (which you should be doing anyway) and notify someone there was a problem.

{Forgive me if I simply stated the obvious}

Re: Yes, the Table is Still There

2008-07-16 09:18 • by alx (unregistered)
206212 in reply to 206188
This just checks to see if items are cached. if not they are added in the cache table.

My understanding is that the code above should increase performance

Re: Yes, the Table is Still There

2008-07-16 09:24 • by Anon (unregistered)
206213 in reply to 206210
dpm:
taylonr:
The turned off post count (instead of just fixing the bug) and forums sped up by several orders of magnitude.

That is quite impressive. Let's say it now takes one second to load a page. Before they disabled the count, it was taking one thousand seconds (three orders of magnitude), which is sixteen minutes and forty seconds. I admire your patience to wait that long for a single page!


I'd assume taylonr measures their orders of magnitude as powers of 2 instead of powers of 10. Therefore, 3 orders of magnitude would only be 8 seconds (still longer than I'd be willing to wait).

Re: Yes, the Table is Still There

2008-07-16 09:30 • by silent d (unregistered)
They need to talk to Aaron from this WTF to learn about “WHERE clauses and other optimization techniques.”

Also, am I the only one that thinks ALTERing db tables on the fly is a bad idea?

Re: Yes, the Table is Still There

2008-07-16 09:33 • by Waffle (unregistered)
206217 in reply to 206209
Thomas P:
Google code search gives the answer:

http://anotherraid.googlecode.com/svn/trunk/ar/itemstats/includes/itemcache.php

The software home page:
http://code.google.com/p/anotherraid/
A World of Warcraft raid tracking, planning and in the future dkp-point system.


RAS Syndrome !

Re: Yes, the Table is Still There

2008-07-16 09:38 • by orv (unregistered)
Is the real WTF that you're using a hunk of opensource code and you didn't file that as a bug or submit a fix?

Re: Yes, the Table is Still There

2008-07-16 09:42 • by Markp
206220 in reply to 206211
ParkinT:
What could have possibly been the intention of the developer who wrote this?


Well, it makes perfect sense if you look at how they purge the cache:

function PurgeItemCache($bNewConnection = false)
{
$this->sql = new SqlHelper(dbhost, dbname, dbuser, dbpass, $bNewConnection);
$this->connected = $this->sql->connected;

$query = "DROP TABLE item_cache";
$this->sql->query($query);
}

Re: Yes, the Table is Still There

2008-07-16 09:53 • by PerdidoPunk
TRWTF is that noone has mentioned the blatantly incorrect use of ALTER TABLE within application code...

Re: Yes, the Table is Still There

2008-07-16 10:01 • by Matt.C
It's good practise to make sure the table is still there.

After all, if it wasn't there, what would you take pictures against?

Re: Yes, the Table is Still There

2008-07-16 10:09 • by FredSaw
206225 in reply to 206185
snoofle:
Select $WTF
From Comments
Where TRWTF = 'Stupid Developer';
This should be a featured comment.

Re: Yes, the Table is Still There

2008-07-16 10:26 • by SawFred (unregistered)
206230 in reply to 206225
FredSaw:
snoofle:
Select $WTF
From Comments
Where TRWTF = 'Stupid Developer';
This should be a featured comment.

This should be a featured comment.

Re: Yes, the Table is Still There

2008-07-16 10:46 • by Morasique (unregistered)
The real WTF is the app apparently has full privileges on the database instead of SELECT/UPDATE. Forget the massive SELECT being run all the time, if you're creating/altering tables at runtime you're doing something wrong

Re: Yes, the Table is Still There

2008-07-16 11:01 • by skin (unregistered)
206238 in reply to 206237
agreed!

Re: Yes, the Table is Still There

2008-07-16 11:03 • by danixdefcon5
206241 in reply to 206237
Morasique:
The real WTF is the app apparently has full privileges on the database instead of SELECT/UPDATE. Forget the massive SELECT being run all the time, if you're creating/altering tables at runtime you're doing something wrong
This code is just waiting for Bobby Tables to come around...

Re: Yes, the Table is Still There

2008-07-16 11:03 • by AlanGriffiths (unregistered)
206242 in reply to 206230
SawFred:
FredSaw:
snoofle:
Select $WTF
From Comments
Where TRWTF = 'Stupid Developer';
This should be a featured comment.

This should be a featured comment.

This is not a featured comment!

Re: Yes, the Table is Still There

2008-07-16 11:05 • by fruey (unregistered)
206243 in reply to 206184
Sorry my bad.

SELECT item_id FROM item_cache

there's no WHERE clause at all, you are totally right. WTF?

Re: Yes, the Table is Still There

2008-07-16 11:07 • by fuffuf
look at the bright side: at least its not creating a new SQL connection every time its called ;D

Re: Yes, the Table is Still There

2008-07-16 11:24 • by th30519
I was sooo disappointed when this post had nothing to do with a wooden table!

Re: Yes, the Table is Still There

2008-07-16 11:40 • by Leak
206261 in reply to 206221
PerdidoPunk:
TRWTF is that noone has mentioned the blatantly incorrect use of ALTER TABLE within application code...

Well, there are uses for ALTER TABLE in an application, but that isn't one of them. At most, they should go into an admin part that's only used every now and then...

np: Underworld - I'm A Big Sister, And I'm A Girl, And I'm A Princess, And This Is My Horse (RiverRun Project)

Re: Yes, the Table is Still There

2008-07-16 12:01 • by savar
206271 in reply to 206197
Arancaytar:

It executes an SQL query that would fetch all rows (no LIMIT). PHP probably fetches the resulting rows, and even if it doesn't, the poor database server has its work cut out.


PHP doesn't fetch any rows automatically, at least not with any of the APIs that I've used.

Still, the DBMS has to perform a full table scan for each comment.

Beyond that, this code is just too stupid to comprehend.

Re: Yes, the Table is Still There

2008-07-16 12:52 • by Andrew (unregistered)
206289 in reply to 206210
dpm:
taylonr:
The turned off post count (instead of just fixing the bug) and forums sped up by several orders of magnitude.

That is quite impressive. Let's say it now takes one second to load a page. Before they disabled the count, it was taking one thousand seconds (three orders of magnitude), which is sixteen minutes and forty seconds. I admire your patience to wait that long for a single page!


Maybe, they're binary orders of magnitude. 2**N grows a bit slower than 10**M. Eight seconds is tolerable.

Re: Yes, the Table is Still There

2008-07-16 13:06 • by AlexG (unregistered)
206293 in reply to 206208
blah:
This code reminds me of a certain interview WTF.

"The alter statements lead you to run the CREATE TABLE query, but there is no CREATE TABLE in SQL. What do you do?"


The alter statements lead you to run the CREATE TABLE query, but there is no CREATE TABLE in SQL. Why is that, Leon?

Re: Yes, the Table is Still There

2008-07-16 13:24 • by DHager (unregistered)
Anon, Andrew:

I too thought: "Maybe he meant binary?"

But on further reflection I can think of any time I've ever seen someone use intelligently use the phrase "orders of magnitude" in anything but base ten.

So no. It can't be binary. If you're someone who wants to justify " orders of magnitude" as a binary scale, then you're just as depraved as those hard drive companies and their "GB=1000KB".

Re: Yes, the Table is Still There

2008-07-16 13:27 • by reading nazi (unregistered)
206303 in reply to 206289
But reading earlier posts is not?

Re: Yes, the Table is Still There

2008-07-16 13:34 • by emurphy
206306 in reply to 206220
Markp:
ParkinT:
What could have possibly been the intention of the developer who wrote this?


Well, it makes perfect sense if you look at how they purge the cache:

function PurgeItemCache($bNewConnection = false)
{
$this->sql = new SqlHelper(dbhost, dbname, dbuser, dbpass, $bNewConnection);
$this->connected = $this->sql->connected;

$query = "DROP TABLE item_cache";
$this->sql->query($query);
}


Given the sterling quality of the original submission, I have to ask: do the damnfools actually purge the cache this way?

Re: Yes, the Table is Still There

2008-07-16 14:17 • by Anrs (unregistered)
206321 in reply to 206210
dpm:
taylonr:
The turned off post count (instead of just fixing the bug) and forums sped up by several orders of magnitude.

That is quite impressive. Let's say it now takes one second to load a page. Before they disabled the count, it was taking one thousand seconds (three orders of magnitude), which is sixteen minutes and forty seconds. I admire your patience to wait that long for a single page!


Maybe your assumption is wrong, and it now takes 0,07 seconds to load the page. And maybe "several" can be just two.

Re: Yes, the Table is Still There

2008-07-16 14:30 • by Monkey Brains (unregistered)
206327 in reply to 206289
Andrew:
dpm:
taylonr:
The turned off post count (instead of just fixing the bug) and forums sped up by several orders of magnitude.

That is quite impressive. Let's say it now takes one second to load a page. Before they disabled the count, it was taking one thousand seconds (three orders of magnitude), which is sixteen minutes and forty seconds. I admire your patience to wait that long for a single page!


Maybe, they're binary orders of magnitude. 2**N grows a bit slower than 10**M. Eight seconds is tolerable.


Perhaps he meant it in an emotional sense and not a mathematical one, being without a stopwatch and all.

Some posters will jump at any chance to display their superior math skills.

Re: Yes, the Table is Still There

2008-07-16 15:22 • by Sigivald (unregistered)
206338 in reply to 206188
So ... the real WTF is the forum software? That has never happened before.


You seem to have an extraneous "the" in there. Let me help:

the real WTF is forum software.

You're welcome.

(Actually, I think the WTF-for-reals is having to use BBCode.)

Re: Yes, the Table is Still There

2008-07-16 15:39 • by duder
206341 in reply to 206261
Leak:
PerdidoPunk:
TRWTF is that noone has mentioned the blatantly incorrect use of ALTER TABLE within application code...

Well, there are uses for ALTER TABLE in an application, but that isn't one of them. At most, they should go into an admin part that's only used every now and then...


I can't think of any situations where altering the database from within application code is the best strategy. However, I'm always on the lookout for better ways to do things. Could you give an example of a use case where altering the DB schema from application code is best practice? (Or maybe you were just trying to be sarcastic in your comment...)

Re: Yes, the Table is Still There

2008-07-16 15:40 • by real_aardvark
206342 in reply to 206302
DHager:
Anon, Andrew:

I too thought: "Maybe he meant binary?"

But on further reflection I can think of any time I've ever seen someone use intelligently use the phrase "orders of magnitude" in anything but base ten.

So no. It can't be binary. If you're someone who wants to justify " orders of magnitude" as a binary scale, then you're just as depraved as those hard drive companies and their "GB=1000KB".
Ah, the black swan excuse. "I've never seen it, so it can't be true." Or, more precisely in your case, "I may have seen it, but I can't remember it, so from a personal cognitive point of view, it can't be true." Or alternatively, by redefining the sense of "intelligently," you are guilty of petitio principii.

I've always been accustomed to think of the final order of magnitude in base ten as "any multiple higher than the square root of ten, and less than ten to the power of 3/2" which just feels like a better bracketing system, somehow.

Anyhow ... you're completely ignoring, amongst other things, Pogson's system for measuring apparent magnitude, which measured orders of magnitude by the intuitively obvious multiple of the fifth root of one hundred.

If you squinted hard at that web page, maybe it just looked enough like half of the North Star ...

Re: Yes, the Table is Still There

2008-07-16 16:00 • by SQB
Thank God it was a db table, not a wooden one.

Imagine a system where every time you request a page, it is printed, put on a wooden table, having a picture taken of it, then that picture is developed, scanned in and shown. But first we need to check if the table is still there, of course. If it is not there, instead of TRUE (picture was taken) or FALSE (picture was not taken), it returns WOODEN_TABLE_NOT_FOUND, leading to the CD tray to open and the server to reset...

Re: Yes, the Table is Still There

2008-07-16 16:58 • by silent d (unregistered)
206367 in reply to 206349
SQB:
Thank God it was a db table, not a wooden one.


If it was a wooden table, the app would need to contact a carpenter every time it needed to CREATE a new table or ALTER an existing one.

But to DROP a table, anyone strong enough to pick up the table in the first place will do.

Re: Yes, the Table is Still There

2008-07-16 17:30 • by Bobbo (unregistered)
206377 in reply to 206321
Anrs:
And maybe "several" can be just two.


Oxford English dicco says maybe it can't.

Just saying, like.
« PrevPage 1 | Page 2Next »

Add Comment