Is favoriting currently broken? October 25, 2006 7:42 AM   Subscribe

Is favoriting currently broken? Doesn't seem to work for me (and it used to). I get a link to the post with a # appended, and don't see the "you have marked this as a favorite" or whatever on the page, nor does the number of favorites on the comment increase by one. Plx fix kthx.
posted by beth to Bugs at 7:42 AM (12 comments total)

Did you install the NoScript extension on Firefox? If so, turn that bugger off sitewide for metafilter.com.
posted by Saucy Intruder at 7:48 AM on October 25, 2006


I'm using Opera.
posted by beth at 7:54 AM on October 25, 2006


No wonder the NoScript extension is causing you trouble, then.
posted by cortex at 8:13 AM on October 25, 2006 [1 favorite]


Buncha smartasses. I love you.

I use FF w/ NoScript w/ MetaFilter allowed site-wide, and I can favorite stuff.

However, for me there is a huge, huge lag between favoriting a comment, seeing the +1 flag appear, and then seeing it in the recent favorites list. This goes for comments of mine that have been favorited, too. There's a bunch of stuff that has been favorited but either never shows up in my recent favorites/d list, or shows up hours or days later.

I'm pretty sure that the issue there isn't with FF and NoScript.
posted by loquacious at 8:22 AM on October 25, 2006


Often this happens for me, but then I reload because I want to see that +1 now now NOW, damnit! And it appears.
posted by I Am Not a Lobster at 8:29 AM on October 25, 2006


there's a 10 minute lag because all the favorite counting isn't done in real time, but just once per ten minutes to save resources. I need to force an update at the moment the user pushes the button though.
posted by mathowie (staff) at 8:29 AM on October 25, 2006


Of course, it's not working right now.
posted by I Am Not a Lobster at 8:30 AM on October 25, 2006


mathowie writes "there's a 10 minute lag because all the favorite counting isn't done in real time, but just once per ten minutes to save resources. I need to force an update at the moment the user pushes the button though."

Favorites are saved in the database, no? Presumably, we have a many-to-many cardinality reduction table, viz. create table favorites ( user_id int, comment_id int, unique constraint foo ( user_id, comment_id ) ). Adding a favorite then means the following SQL: "insert into favorites ( user_id, comment_id ) values ( @user_id, @comment_id)"

Counting favorites is "select count(*) from favorites where comment_id = @comment_id", or more generally, "select comment_id, count(*) from favorites group by comment_id".

Here's the thing: if favorites has correctly constructed indices, the bulk of the counting cost actually takes place in the update (which you aren't deferring to every 10 minutes). With the right indices, the cost of counting should be negligible, as the base table doesn't need to be consulted, the whole thing is an index scan, and the update has already forced the loading of the indices into memory.

Actual metric: I happen to have a 56 Million record MySQL table with indices isomorphic to what a favorites table should have. Getting (the number that is isomorphic to) the "number of favorites" for one "comment" takes from 0.0022 seconds to a longest time 0.0101 seconds. That is, the maximum time cost is about one one-hundredth of a second. That's with MySQL running on the same desktop workstation I'm using to type this comment, and run Firefox and bunches of other stuff including two other database servers.

That's the whole cost, including transport to the client; the actual server cost is about 5 ten-thousandths of second.
posted by orthogonality at 9:48 AM on October 25, 2006


orthogonality, I do stuff as you describe, it's just that the select count(*) part has a "yo, cache this query for ten minutes and keep it in memory instead of even touching the db" in coldfusion speak. Lots of queries on the site are like that because the server has 2Gb of RAM in it and the web server itself doesn't use a ton of that so I keep hundreds of common queries in memory because they run faster that way.

I just need to add some code after the "add this to the favorites table" that says "yo, refresh the cached query that includes that favorite I just added, dawg" which is a slight pain in the ass since there is one favorites table for potentially a gazillion counts all over the site.

I could just remove the "yo, cache this" thing from the count queries on the pages.
posted by mathowie (staff) at 10:11 AM on October 25, 2006


Yo no query Taco Bell.
posted by mr_crash_davis at 10:27 AM on October 25, 2006


Punch the keys for gods sake!
posted by Roger Dodger at 4:49 PM on October 25, 2006


Good grief. ColdFusion's syntax is pretty 'street'. No wonder I could never get to grips with it.
posted by blag at 5:02 PM on October 25, 2006


« Older Sometimes I am someone else   |   Pony: seeing tags from outside the thread Newer »

You are not logged in, either login or create an account to post comments