Website/database question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Izzy
    Snek
    FFR Simfile Author
    • Jan 2003
    • 9195

    #16
    Re: Website/database question

    Maybe you could do some kind of massive join of all the levels tables and then query it all at once.

    Comment

    • Reincarnate
      x'); DROP TABLE FFR;--
      • Nov 2010
      • 6332

      #17
      Re: Website/database question

      Originally posted by Velocity
      Each of FFR's levels are stored as a separate level in the database, so when doing levelranks, it grabs the entire song list, then loops every level getting your score from each table. So it ends up doing a massive amount of small queries. This is also why that page is cached for 15 minutes each time it's load.

      It's terribly slow.
      What's the smart way to do this? When you say it's a "separate level" in the database, do you mean a separate table? Like Level1 table, Level2 table, etc.

      I thought having lots of small queries was technically a good thing with respect to datatable normalization?

      Comment

      • arcnmx
        nanodesu~
        • Jan 2013
        • 503

        #18
        Re: Website/database question

        Originally posted by Reincarnate
        What's the smart way to do this? When you say it's a "separate level" in the database, do you mean a separate table? Like Level1 table, Level2 table, etc.

        I thought having lots of small queries was technically a good thing with respect to datatable normalization?
        The smart way is to not do this, just have one single table, and set up an index on the levelid/whatever to allow queries to work as well as if they were in separate tables, without the retardedness that comes with actually using separate tables.

        Originally posted by Izzy
        Maybe you could do some kind of massive join of all the levels tables and then query it all at once.
        This won't improve anything due to the lack of an index on the element you're querying (in levelranks case, userid). It would probably also max out memory usage and fail anyway.
        Last edited by arcnmx; 02-18-2014, 07:38 PM.


        FMO AAAs (1): Within Life :: FGO AAAs (1): Einstein-Rosen Bridge

        Comment

        • Velocity
          Doing the wrong thing the right way since 2010.
          FFR Simfile Author
          FFR Administrator
          • Jul 2007
          • 1817

          #19
          Re: Website/database question

          Originally posted by Reincarnate
          What's the smart way to do this? When you say it's a "separate level" in the database, do you mean a separate table? Like Level1 table, Level2 table, etc.
          Level1, Level2, Level3, .... Level2145

          The table layout has changed over the years so indexes on older levels don't match the new levels.

          Originally posted by Reincarnate
          I thought having lots of small queries was technically a good thing with respect to datatable normalization?
          It's generally bad.

          Also since I've only learned this stuff working on FFR, I have no idea whats better. I just change the queries and time the results and pick the consistently fast one.
          Last edited by Velocity; 02-18-2014, 07:41 PM.

          Comment

          • Reincarnate
            x'); DROP TABLE FFR;--
            • Nov 2010
            • 6332

            #20
            Re: Website/database question

            I find that interesting -- so you're saying it's actually better to have it all in one table with well-chosen indexes?

            How do you then decide what to put into another table and what to lump together?

            Although I guess it makes sense: If you have a table called "level_score_data" or something, it would just contain a key identifier (song ID or something) with the userid (person who played it) and the corresponding score. Then you could just query that to calculate the levelranks, yes?

            Comment

            • arcnmx
              nanodesu~
              • Jan 2013
              • 503

              #21
              Re: Website/database question

              Originally posted by Reincarnate
              I find that interesting -- so you're saying it's actually better to have it all in one table with well-chosen indexes?

              How do you then decide what to put into another table and what to lump together?
              Right. You could kinda say that indexes split up tables into many small minitables that are easy and quick to query.

              Basically, if you're making multiple tables with the exact same column structure / holding the same data, you're likely doing something very wrong.

              Originally posted by Reincarnate
              Although I guess it makes sense: If you have a table called "level_score_data" or something, it would just contain a key identifier (song ID or something) with the userid (person who played it) and the corresponding score. Then you could just query that to calculate the levelranks, yes?
              Mmhm. The alternative, level_score_data9999 without a songid field results in mayhem and slowness.


              FMO AAAs (1): Within Life :: FGO AAAs (1): Einstein-Rosen Bridge

              Comment

              • Reincarnate
                x'); DROP TABLE FFR;--
                • Nov 2010
                • 6332

                #22
                Re: Website/database question

                Is there a downside to just indexing everything?

                Comment

                • cedolad
                  moonchild~
                  FFR Simfile Author
                  • Jan 2007
                  • 6879

                  #23
                  Re: Website/database question

                  I feel like there's a main point to all of this...

                  But anyway, a few downsides (that I know of) are that each of the indexes requires space equal to the size and numbers of columns, as well as the size of the table. So I'd imagine with 1,500+ songs currently in-game that's a pretty big sized number.

                  INSERT or DELETE operations for the table need to be updated for each index in the table. Same with UPDATE operations that changes values of the index.

                  LOAD practically rebuilds the entire index, but using a MODIFIED BY parameter on the LOAD command can be used to override the index PCTFREE when the index was initially created.

                  Also each index can add alternative access paths that the optimizer may consider for a query, so that could kill compilation time.


                  There could be more to it though ._.

                  Comment

                  • emerald000
                    the Mathemagician~
                    • Nov 2005
                    • 1320

                    #24
                    Re: Website/database question

                    Originally posted by Reincarnate
                    Is there a downside to just indexing everything?
                    It takes space. A lot of it for big tables. It also takes some time with each insert to update all the indexes.

                    The easiest way to build indexes is on a need basis. For every query you make, check if it uses an index and if not, create one. EXPLAIN can be a good tool to see if your indexes work as expected. PS: They often don't.

                    Comment

                    • Izzy
                      Snek
                      FFR Simfile Author
                      • Jan 2003
                      • 9195

                      #25
                      Re: Website/database question

                      Originally posted by Reincarnate
                      Is there a downside to just indexing everything?
                      If you were only ever reading and never writing to the tables then probably not. You have to do some analysis on which tables and columns are constantly getting written to the most and which are getting read the most and choose indexes based on that.

                      Comment

                      • Velocity
                        Doing the wrong thing the right way since 2010.
                        FFR Simfile Author
                        FFR Administrator
                        • Jul 2007
                        • 1817

                        #26
                        Re: Website/database question

                        Originally posted by cedolad
                        But anyway, a few downsides (that I know of) are that each of the indexes requires space equal to the size and numbers of columns, as well as the size of the table. So I'd imagine with 1,500+ songs currently in-game that's a pretty big sized number.
                        1,500 is nothing compared to the 1.877 million users. ;D
                        And 32 million score entries across every level table.

                        Comment

                        • devonin
                          Very Grave Indeed
                          Event Staff
                          FFR Simfile Author
                          • Apr 2004
                          • 10120

                          #27
                          Re: Website/database question

                          Just permanently nuke every account that hasn't logged in for the preceding two years. Should cut that number down subsantially.

                          Comment

                          • justin_ator
                            🥓<strong><span style="col
                            • Mar 2007
                            • 7648

                            #28
                            Re: Website/database question

                            ^

                            You could even do the last four years and probably still clear out a good chunk of the db

                            What's the possibility of sending out account termination emails to anyone that hasn't logged in for two years?

                            Comment

                            • Velocity
                              Doing the wrong thing the right way since 2010.
                              FFR Simfile Author
                              FFR Administrator
                              • Jul 2007
                              • 1817

                              #29
                              Re: Website/database question

                              Originally posted by devonin
                              Just permanently nuke every account that hasn't logged in for the preceding two years. Should cut that number down subsantially.
                              Originally posted by justin_ator
                              ^

                              You could even do the last four years and probably still clear out a good chunk of the db

                              What's the possibility of sending out account termination emails to anyone that hasn't logged in for two years?
                              This breaks thing. Also Impossible, emails don't work 99% of the time.

                              Comment

                              • Untimely Friction
                                D6 Challeneged
                                • Aug 2012
                                • 1267

                                #30
                                Re: Website/database question

                                This reminds me ofwhen tass put up the last offline capable engine and it could just be pulled from cache alongside a few other files, good read here.

                                Comment

                                Working...