- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
It's only fetching the current item_id... not the whole table, unless I'm very much mistaken...
Admin
With a computers, we can bring OCD to the next level!
Admin
Admin
Select $WTF From Comments Where TRWTF = 'Stupid Developer';
Admin
better to be safe than sorry
Admin
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.
Admin
So ... the real WTF is the forum software? That has never happened before.
Admin
Isn't TRWTF the forum software on THIS site?
Admin
They're allocating 100 characters for the item_id? What are they putting in there, the item's full name and postal address?
Admin
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.
Admin
Brillant!
Admin
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.
Admin
And here I thought that the WTF was the "item cache" which is slower than what it's intended to cache...
Admin
Win.
Admin
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?"
Admin
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.
Admin
Admin
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}
Admin
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
Admin
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).
Admin
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?
Admin
RAS Syndrome !
Admin
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?
Admin
Well, it makes perfect sense if you look at how they purge the cache:
Admin
TRWTF is that noone has mentioned the blatantly incorrect use of ALTER TABLE within application code...
Admin
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?
Admin
Admin
Admin
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
Admin
agreed!
Admin
Admin
Admin
Sorry my bad.
SELECT item_id FROM item_cache
there's no WHERE clause at all, you are totally right. WTF?
Admin
look at the bright side: at least its not creating a new SQL connection every time its called ;D
Admin
I was sooo disappointed when this post had nothing to do with a wooden table!
Admin
np: Underworld - I'm A Big Sister, And I'm A Girl, And I'm A Princess, And This Is My Horse (RiverRun Project)
Admin
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.
Admin
Maybe, they're binary orders of magnitude. 2N grows a bit slower than 10M. Eight seconds is tolerable.
Admin
The alter statements lead you to run the CREATE TABLE query, but there is no CREATE TABLE in SQL. Why is that, Leon?
Admin
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".
Admin
But reading earlier posts is not?
Admin
Given the sterling quality of the original submission, I have to ask: do the damnfools actually purge the cache this way?
Admin
Maybe your assumption is wrong, and it now takes 0,07 seconds to load the page. And maybe "several" can be just two.
Admin
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.
Admin
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.)
Admin
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...)
Admin
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 ...
Admin
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...
Admin
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.
Admin
Oxford English dicco says maybe it can't.
Just saying, like.