You're looking at Less Wrong's discussion board. This includes all posts, including those that haven't been promoted to the front page yet. For more information, see About Less Wrong.

gjm comments on Open Thread Feb 29 - March 6, 2016 - Less Wrong Discussion

4 Post author: Elo 28 February 2016 10:11PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (285)

You are viewing a single comment's thread. Show more comments above.

Comment author: gjm 02 March 2016 12:27:06PM 1 point [-]

I agree that this is a plausible explanation ("not a straightforward SQL database" is an understatement) but have no specific information about whether it's actually correct; do you?

Comment author: Viliam 02 March 2016 01:21:15PM *  2 points [-]

It's the same database structure as Reddit -- a database in a database anti-pattern. Quoting Wikipedia:

In the database world, developers are sometimes tempted to bypass the RDBMS, for example by storing everything in one big table with three columns labelled entity ID, key, and value. While this entity-attribute-value model allows the developer to break out from the structure imposed by an SQL database, it loses out on all the benefits, since all of the work that could be done efficiently by the RDBMS is forced onto the application instead. Queries become much more convoluted, the indexes and query optimizer can no longer work effectively, and data validity constraints are not enforced. Performance and maintainability can be extremely poor.

LW database is exactly like this. Look at the existing scripts and despair.

Comment author: gjm 02 March 2016 03:12:41PM 2 points [-]

Yup, it's pretty horrible. But on the face of it -- I know that appearances can deceive -- it seems like you could iterate (inefficiently, but it's not like this is going to be done often) over all the votes with a given voter-ID as in the "slow" case of user_downvote_karma and call Vote.vote with dir=None as defined in vote.py for each. Something along these lines, though it probably consists entirely of bugs:

from r2.models import Account, Link, Vote
user = Account._by_name('Eugine\_Nier')
# list() to make sure enumeration is done before we start changing the votes
# (dunno if we actually need to do that)
votee_ids = list([v.c._thing2_id for v in Vote._query(Vote.c._thing1_id == user._id)])
# dir = None to remove a vote
# ip = None because ip isn't needed when not creating a new vote
for votee_id in votee_ids: Vote.vote(user, Link._byID(votee_id), None, None)