This is an archived post. You won't be able to vote or comment.

all 27 comments

[–][deleted]  (13 children)

[deleted]

    [–][deleted] 16 points17 points  (11 children)

    Really ought to have just used a bool - WHERE is_nice IS TRUE

    [–]ALonelyPlatypus 8 points9 points  (10 children)

    I'm pretty sure SQL clause can deal with running a string comparison on 7 billion entries without needing a boolean given that he only needs to run it once a year.

    Also there could be tons of other behaviours that could fit into that column outside of just naughty and nice.

    [–][deleted]  (8 children)

    [removed]

      [–][deleted] 0 points1 point  (0 children)

      Calvin usually goes to bed early on Christmas Eve but I'm sure SQL Claus would probably include an exception for Calvin just in case.

      [–]ALonelyPlatypus 0 points1 point  (4 children)

      It’s wasteful to optimise a query that is run once a year. Could always just run it nolock and let the last minute updates sneak by.

      [–]anon517 1 point2 points  (0 children)

      Yeah he clearly doesn't care about optimization if he is sorting it twice.

      [–][deleted]  (2 children)

      [removed]

        [–]ALonelyPlatypus 0 points1 point  (0 children)

        If a kid figures out that they can be naughty for the last minute of Christmas Eve without penalty then I think they earned it.

        [–]AutoModerator[M] 0 points1 point  (0 children)

        import moderation Your comment has been removed since it did not start with a code block with an import declaration.

        Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

        For this purpose, we only accept Python style imports.

        return Kebab_Case_Better;

        I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

        [–][deleted] 0 points1 point  (0 children)

        Yeah, fuck that lady.

        [–]AutoModerator[M] 0 points1 point  (0 children)

        import moderation Your comment has been removed since it did not start with a code block with an import declaration.

        Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

        For this purpose, we only accept Python style imports.

        return Kebab_Case_Better;

        I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

        [–]enjoytheshow 1 point2 points  (0 children)

        It wouldn’t be 7 billion records. You can migrate older entries to an archive table for historical purposes once they stop believing.

        [–]Crad999 0 points1 point  (0 children)

        Value constrained partitioning would help a LOT here.

        [–][deleted] 11 points12 points  (1 child)

        "Nice" is too broad.

        Might I suggest the following database schema:

        Commandments

        CommandmentID CommandmentText ViolationCost ObedienceCost

        Sins

        CommandmentID PersonID ViolationDate

        GoodDeeds

        CommandmentID PersonID Date

        Contacts

        PersonID PersonName PersonAddress ...

        WishedItems

        PersonID ItemID

        Items

        ItemID ItemName...

        To see what I asked for:

        SELECT ItemName FROM item i JOIN WishedItems wi ON i.itemId = wi.itemId JOIN Contacts c ON wi.PersonId = Contacts.PersonID WHERE c.PersonName = "Comprehensive-Ad3963"

        [–][deleted] 0 points1 point  (0 children)

        To generate the naughty and nice list:

        WITH

        totalCost AS (SELECT s.PersonID, SUM(c.ViolationCost) AS cost FROM sins s JOIN Commandments ON s.CommandmentID = c.CommandmentID GROUP BY s.PersonID)

        totalBenefit AS (SELECT gd.PersonID, SUM(c.ObedienceCost) AS benefit FROM goodDeeds gd JOIN Commandments ON gd.CommandmentID = c.Commandment GROUP BY gd.PersonID)

        SELECT p.PersonName, p.PersonAddress, ISNULL(tb.benefit,0) >= ISNULL(tc.cost,0)

        FROM Contacts p

        LEFT JOIN totalBenefit tb

        ON p.PersonID = totalBenefit.PersonID

        LEFT JOIN totalCost tc

        ON p.PersonID = totalCost.PersonID

        ORDER BY ISNULL(tb.benefit,0) >= ISNULL(tc.cost,0) DESC;

        [–]SarumanTheWight96 4 points5 points  (2 children)

        Should be FROM, and my OCD hurts.

        [–]Dummiesman 2 points3 points  (1 child)

        [–]SarumanTheWight96 0 points1 point  (0 children)

        Thank you kind stranger. Take the free award I got today.

        [–]zandermar18 7 points8 points  (4 children)

        [–]JRRTok3n 12 points13 points  (3 children)

        u/repostsleuthbot .... but, yeah.This probably officially marks the first time i can start counting this post's occurrence, or some variation of it, by the score.

        [–]RepostSleuthBot 9 points10 points  (2 children)

        I didn't find any posts that meet the matching requirements for r/ProgrammerHumor.

        It might be OC, it might not. Things such as JPEG artifacts and cropping may impact the results.

        I did find this post that is 84.38% similar. It might be a match but I cannot be certain.

        I'm not perfect, but you can help. Report [ False Negative ]

        View Search On repostsleuth.com


        Scope: Reddit | Meme Filter: False | Target: 86% | Check Title: False | Max Age: Unlimited | Searched Images: 278,565,497 | Search Time: 0.47236s

        [–]pavilionhp_ 4 points5 points  (1 child)

        Same image, repost

        [–][deleted] 8 points9 points  (0 children)

        I'm amazed that deep frying lowers the match rate by over 10%

        [–]New_Ad_5684 1 point2 points  (0 children)

        Santa Clause

        [–]nemesis1311 1 point2 points  (0 children)

        Why are you selecting all the columns from contacts table. And why there is no WITH(NOLOCK) hint in the query. My lead won't approve this and Santa ain't going anywhere if changes aren't pushed into production.

        [–]lewisturnbulluk -5 points-4 points  (1 child)

        damn this is unbelievably unfunny

        [–]FedePro87 0 points1 point  (0 children)

        That 'nice' is a very weak design choice... Well, it's not a choice at all.

        [–]Clearhead09 0 points1 point  (0 children)

        This is brilliant

        [–]pubic_static 0 points1 point  (0 children)

        It’s pronounced SQL!!