• (nodebb)

    Hopefully everyone learned a lesson, especially the company trying to hire programmers on the cheap.

    The ongoing history of articles here suggests strongly that the company would never learn any useful lessons from that. They might be taught those lessons, but they sure as egcs is egcs wouldn't learn them.

  • 516052 (unregistered)

    If it's stupid and it works than it's still stupid but you don't care because you got it on the cheap.

    Management 101.

  • (nodebb)

    There's no excuse for the second part and how the ID is checked in the array, but if the valid IDs are sparse, I'll excuse fetching the whole table thereof (a shame about the rest of the columns though).

  • (nodebb) in reply to Medinoc

    As old content is retired it's hard-deleted from the database (rather than updating a "hide me" column), so valid IDs are sparse. Given the "many years ago" era there are probably a few dozen rightsides, max, so the kid following worst practices isn't going to get bitten by time or space constraints either.

  • Lothar (unregistered)

    10 bucks that they've now fireed all the expensive programmers and are using AI vibe coding instead.

  • CrustyOldITGuy (unregistered)

    Perhaps: Select Rightside where Not In a list of used so fars. But after 5 or 10 hits erase the list and start anew.

  • (nodebb) in reply to 516052

    If it's stupid and it works than it's still stupid

    Ah. Maxim 43, which states in full: "If it's stupid and it works, it's still stupid and you're lucky."

  • Jaloopa (unregistered)
    SELECT TOP (1) * FROM rightside ORDER BY NEWID()
    

    Not sure if that works anywhere outside of SQL Server but it's a quick and dirty "select a random record" version I've used before

  • (nodebb) in reply to Jaloopa

    It doesn't look like it should work because I'd expect the ORDER BY to require a column name, but it is documented as a way to select a random record (or several by changing to TOP n where n is hew number of random rows you want) in the Microsoft transact-sql documentation.

  • Álvaro González (github) in reply to Jaloopa

    If I recall correctly the MySQL idiom was very similar to that, ORDER BY RAND(). Despite everybody doing it that way, it was not particularly good because the database server would calculate a random number for every matching row in the query. It was only fast because we all had tiny datasets.

  • (nodebb) in reply to jeremypnet

    I'd expect the ORDER BY to require a column name

    ORDER BY accepts any expression, not just bare columns. Of course ORDER By clauses that use columns names can be assisted by an index while expression-based ordering doesn't typically use an index. MS SQL Server supports indexes on computed columns, so it's actually possible to use an index for expression-based ORDER BY terms.

  • theArtOfRandomness (unregistered)

    Hopefully everyone learned a lesson, especially the company trying to hire programmers on the cheap.

    Monkey paw: granted, entry-level positions now need 5 years of experience

  • (nodebb)

    Surely you could save computational power by computing a random value when the data is added to the table, and then do an ORDER BY on that column and grab the first item. Super fast!

  • no (unregistered) in reply to prueg

    a variation of the prng algorithm from the xkcd 221 standard

Leave a comment on “A Random Article”

Log In or post as a guest

Replying to comment #705100:

« Return to Article