Live data from Hacker News

A terrible schema from a clueless programmer

rachelbythebay.com

391–400 of 493 posts

Re: A terrible schema from a clueless programmer

#391

Earlier quoted context omitted.

I would expect most seniors to want a set of eyes across their work doing any form of authk or z. If only to share blame :p

> authk I've always seen authn. Where'd you pick this usage up?

good question! I meant authn. I think I just subbed in the phonic from the ..cation part of the word.

Re: A terrible schema from a clueless programmer

#392

Why exactly would it be so bad to just put a suitable index on the table containing strings? The time complexity of the resulting search would be the same, so I assume there will be some constant factor slowdowns. Is it that indices over string fields are stored inefficiently on disk? (If so, can that not be fixed in the db engine directly?) Or is this fine today but wasn't fine 15 years ago?

Yeah, while this is not optimal (ip should be converted into integer, time should be ts), the table would be small (as old entries could be safely deleted). The only real issue is the lack of indices. Also is helo field even needed?

IP should NOT be an integer. IPv6 does not fit in a database integer. MySQL has functions to convert to bytes.

Even better, use a database with a proper inet datatype. That way you get correctness, space efficiency, and ability to intelligently index.

Re: A terrible schema from a clueless programmer

#393
post #360

Earlier quoted context omitted.

Fork and fix? I’ve personally been pleasantly surprised by how fast maintainers will merge a PR I submit. If it causes an issue with our own systems it also gives me a very good justification for doing it.

In Oracle's proprietary system?

Oracle doesn't appear to maintain the DBD::Oracle Perl client module.

Re: A terrible schema from a clueless programmer

#395
post #388

Earlier quoted context omitted.

> authk I've always seen authn. Where'd you pick this usage up?

You need to distinguish authentication from authorization. "auth9n" and "auth8n" might be a slight bit too obsure for the purpose.

Generally authentication is authn and authorization is authz

Re: A terrible schema from a clueless programmer

#396
post #392

Earlier quoted context omitted.

Yeah, while this is not optimal (ip should be converted into integer, time should be ts), the table would be small (as old entries could be safely deleted). The only real issue is the lack of indices. Also is helo field even needed?

IP should NOT be an integer. IPv6 does not fit in a database integer. MySQL has functions to convert to bytes. Even better, use a database with a proper inet datatype. That way you get correctness, space efficiency, and ability to intelligently index.

In 2002 it definitely should have been an integer.

In 2021 I’d recommend just turning off the IPv6 allocation or deleting it from DNS like this site does.

Re: A terrible schema from a clueless programmer

#398
post #268

Earlier quoted context omitted.

I really don't understand your general thrust here. MySql certainly had lots of issues in 2003, but being able to support multi-column indexes was not one of them. Her analysis is simply wrong - it is wrong now and was wrong then. Here is the doc from MySql v3.23: 7.4.2 Multiple-Column Indexes MySQL can create composite indexes (that is, indexes on multiple columns). An index may consist of up to 16 columns. For cert…

As I said already: "mysql could index strings" and "using a compound index over four varchar columns would've worked out well" are significantly different propositions. To be more verbose about it - there is an important difference between "can be created" and "will perform sufficiently well on whatever (likely scavenged) hardware was assigned to the internal IT system in question." I wouldn't be surprised if the "se…

A composite index is literally just concatenating the fields and then indexing that value. This is not technology that was out of reach of MySQL in 2002 and there is no reason to presume it was so when TFA clearly described the problem as a complete lack of indexes.

Re: A terrible schema from a clueless programmer

#399

Earlier quoted context omitted.

Old best practice for InnoDB performance was actually to never use foreign keys because of these locking issues. Not sure if that's the case in 2021.

InnoDB uses row-level locking, and foreign keys are (usually) a great feature to ensure data integrity. But using multiple foreign keys from tables `a`,`b` as a composite index for table `x` can cause deadlock if both are being updated in rapid succession, because an update on `a` gets a lock on `x`, which needs a read lock on `b` which is waiting for the lock from `a` to be released. I try to never structure multipl…

This is fascinating, thanks for sharing.

Re: A terrible schema from a clueless programmer

#400
post #280

Earlier quoted context omitted.

That's pretty beside the point though, the concept of indexing had existed for decades even prior to that.

The quote was "database optimization features" and the scope was "MySQL as of 2002". Of course, even my old DBase II handbook talks about indexes - all that's old hat. MySQL had them, too. MySQL also used to have a long-earned reputation as a toy database though, and MySQL in 2002 was right within the timeframe where it established that reputation. So yeah, you could add indexes, but did they speed things up (as in t…

I was there and I don't remember it like you describe. MySQL was certainly not a toy database in 2002. I learned PHP from a book called "PHP and MySQL". They went together like white on rice. Every forum software used it. Hell, even today Uber uses MySQL at a VERY large scale to power their schemaless database.
Post reply on HN