My SQL is a bit old and rusty, but last time I was into the practice
it was recommended to avoid the following:

SELECT * FROM mytable ORDER BY id DESC LIMIT 1;

but rather, do:

SELECT * FROM mytable WHERE ID = (SELECT MAX(id) FROM mytable);

(typos notwithstanding)

To avoid ordering the whole table on every select. Otoh, perhaps smart
schedulers finally optimize this nowadays. I guess EXPLAIN is the best
way to determine that for your box.

Greetings,

Hraban

2011/1/16 Anand Chitipothu <[email protected]>:
> 2011/1/16 geekbuntu <[email protected]>:
>> just noticed a lot of errors in my log from doing selects - is this
>> normal?
>>
>> the select code is:
>> db.select('blog', what='id, title', order='id DESC', limit=1)
>>
>>
>> errors are:
>> [Sun Jan 16 12:02:50 2011] [error] [client 67.246.108.253] , referer:
>> http://www.holyarmor.org/
>> [Sun Jan 16 12:05:50 2011] [error] 0.0 (1): SELECT * FROM blog
>> [Sun Jan 16 12:05:50 2011] [error] 0.0 (2): SELECT count(*) as total
>> FROM blog
>> [Sun Jan 16 12:05:50 2011] [error] 0.0 (3): SELECT count(*) as total
>> FROM blog
>> [Sun Jan 16 12:05:50 2011] [error] 0.0 (4): SELECT * FROM blog ORDER
>> BY id desc LIMIT 1
>> [Sun Jan 16 12:05:51 2011] [error] 0.0 (1): SELECT * FROM blog
>> [Sun Jan 16 12:05:51 2011] [error] 0.0 (2): SELECT count(*) as total
>> FROM blog
>> [Sun Jan 16 12:05:51 2011] [error] 0.0 (3): SELECT count(*) as total
>> FROM blog
>> [Sun Jan 16 12:05:51 2011] [error] 0.0 (4): SELECT * FROM blog ORDER
>> BY id desc LIMIT 1
>>
>> is there a way to fix this so that it doesn't report errors?
>
> web.py prints queries to stderr in debug mode. The debug mode is
> disabled in production by detecting the running environment. How are
> you deploying you app?
>
> You can disable debug mode explicitly by adding the following line
> before the db is created.
>
> web.config.debug = False
>
> Anand
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web.py" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/webpy?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to