Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. How NOT to optimize a database!

How NOT to optimize a database!

Scheduled Pinned Locked Moved The Lounge
c++performancephpdatabasecom
57 Posts 26 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Nish Nishant

    Chris Maunder wrote:

    I'm sure lots of members are biting their tongues on this one.

    Well it was not by accident that I posted it here and not the GIT. ;)

    Regards, Nish


    My technology blog: voidnish.wordpress.com Part 2 in my WinRT/C++ series : Visual C++ and WinRT/Metro - Databinding Basics

    C Offline
    C Offline
    Chris Maunder
    wrote on last edited by
    #10

    :-D

    cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

    1 Reply Last reply
    0
    • N Nish Nishant

      http://articles.economictimes.indiatimes.com/2011-10-23/news/30313183_1_diwali-rush-western-railway-berths[^] TLDR : The IT company that designed the online reservation system for India's western railways used a 3-character field storing numbers to hold the reservation token (001 to 999) on a per-train basis. This limit was never ever hit until last week when (due to Diwali, an Indian festival) enough people made online bookings that the database crashed and with it the reservation system. Funny side-bit : 3 characters (even non-Unicode) is still larger than a short int (memory wise). So whoever did this pseudo-optimization was terribly ignorant.

      Regards, Nish


      My technology blog: voidnish.wordpress.com Part 2 in my WinRT/C++ series : Visual C++ and WinRT/Metro - Databinding Basics

      P Offline
      P Offline
      Pascal Ganaye
      wrote on last edited by
      #11

      The sad thing is that it is one column in a 300 pages specification. The guy who do the specifications often do not have the technical expertise to know that a 16 bit integer can store 32000 values in 2 bytes. The programmer usually does, but the programmer is part of the chain. Every programmer is confronted to this problem at times. Do I raise the issue? If you raise the issue it will waste a few hours and you might end up finishing your development late. Also If you raise issues a bit too often you're quickly categorized as annoying git who can't follow orders. This is not the best way to progress in a company. I am not sure if this is true in India but this is true in the countries I worked in. If you shut up and follow orders, you won't get blamed and if you're on time you'll perhaps be promoted. The blame goes on the guy who did the specs despite the fact that the programmer is the best person to notice and fix the issue. To me this is the waterfall drama.

      A N Sander RosselS A 4 Replies Last reply
      0
      • P Pascal Ganaye

        The sad thing is that it is one column in a 300 pages specification. The guy who do the specifications often do not have the technical expertise to know that a 16 bit integer can store 32000 values in 2 bytes. The programmer usually does, but the programmer is part of the chain. Every programmer is confronted to this problem at times. Do I raise the issue? If you raise the issue it will waste a few hours and you might end up finishing your development late. Also If you raise issues a bit too often you're quickly categorized as annoying git who can't follow orders. This is not the best way to progress in a company. I am not sure if this is true in India but this is true in the countries I worked in. If you shut up and follow orders, you won't get blamed and if you're on time you'll perhaps be promoted. The blame goes on the guy who did the specs despite the fact that the programmer is the best person to notice and fix the issue. To me this is the waterfall drama.

        A Offline
        A Offline
        AspDotNetDev
        wrote on last edited by
        #12

        Pascal Ganaye wrote:

        The guy who do the specifications often do not have the technical expertise to know that a 16 bit integer can store 32000 values in 2 bytes

        Ahem. 65,536 values.

        Somebody in an online forum wrote:

        INTJs never really joke. They make a point. The joke is just a gift wrapper.

        N P N 3 Replies Last reply
        0
        • P Pascal Ganaye

          The sad thing is that it is one column in a 300 pages specification. The guy who do the specifications often do not have the technical expertise to know that a 16 bit integer can store 32000 values in 2 bytes. The programmer usually does, but the programmer is part of the chain. Every programmer is confronted to this problem at times. Do I raise the issue? If you raise the issue it will waste a few hours and you might end up finishing your development late. Also If you raise issues a bit too often you're quickly categorized as annoying git who can't follow orders. This is not the best way to progress in a company. I am not sure if this is true in India but this is true in the countries I worked in. If you shut up and follow orders, you won't get blamed and if you're on time you'll perhaps be promoted. The blame goes on the guy who did the specs despite the fact that the programmer is the best person to notice and fix the issue. To me this is the waterfall drama.

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #13

          Interesting points!

          Regards, Nish


          My technology blog: voidnish.wordpress.com Part 2 in my WinRT/C++ series : Visual C++ and WinRT/Metro - Databinding Basics

          1 Reply Last reply
          0
          • A AspDotNetDev

            Pascal Ganaye wrote:

            The guy who do the specifications often do not have the technical expertise to know that a 16 bit integer can store 32000 values in 2 bytes

            Ahem. 65,536 values.

            Somebody in an online forum wrote:

            INTJs never really joke. They make a point. The joke is just a gift wrapper.

            N Offline
            N Offline
            Nish Nishant
            wrote on last edited by
            #14

            He probably kept aside the sign bit to specify gender. :-D

            Regards, Nish


            My technology blog: voidnish.wordpress.com Part 2 in my WinRT/C++ series : Visual C++ and WinRT/Metro - Databinding Basics

            1 Reply Last reply
            0
            • N Nish Nishant

              http://articles.economictimes.indiatimes.com/2011-10-23/news/30313183_1_diwali-rush-western-railway-berths[^] TLDR : The IT company that designed the online reservation system for India's western railways used a 3-character field storing numbers to hold the reservation token (001 to 999) on a per-train basis. This limit was never ever hit until last week when (due to Diwali, an Indian festival) enough people made online bookings that the database crashed and with it the reservation system. Funny side-bit : 3 characters (even non-Unicode) is still larger than a short int (memory wise). So whoever did this pseudo-optimization was terribly ignorant.

              Regards, Nish


              My technology blog: voidnish.wordpress.com Part 2 in my WinRT/C++ series : Visual C++ and WinRT/Metro - Databinding Basics

              A Offline
              A Offline
              Andy Brummer
              wrote on last edited by
              #15

              From the US, I think the response would be they can fit 999 people on a train? :-D On the other side of the situation. The guy in charge of the India unique ID project gave a talk at the foundation where I work. That is a mind boggling huge project, and seem to be doing good planning to prevent these kinds of issues.

              Curvature of the Mind now with 3D

              N 1 Reply Last reply
              0
              • C Chris Maunder

                I'm sure lots of members are biting their tongues on this one.

                cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #16

                Oh, you have no idea. I dare not post a single story about the outside "help" we have right now.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak

                1 Reply Last reply
                0
                • C Chris Maunder

                  I'm sure lots of members are biting their tongues on this one.

                  cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                  H Offline
                  H Offline
                  Henry Minute
                  wrote on last edited by
                  #17

                  Whistles tunelessly and saunters slowly away.................

                  Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.

                  1 Reply Last reply
                  0
                  • C Chris Maunder

                    Chris Meech wrote:

                    Today, the moment 999 was breached, the program developed a bug

                    No, the bug was already there, guys.

                    cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                    Sander RosselS Offline
                    Sander RosselS Offline
                    Sander Rossel
                    wrote on last edited by
                    #18

                    Unless they created true Artificial Intelligence... Or is that called Virtual Intelligence? :D

                    It's an OO world.

                    public class Naerling : Lazy<Person>{}

                    1 Reply Last reply
                    0
                    • C Chris Meech

                      From the article, "We could not foresee that e-tickets would ever reach 1,000. This number was beyond all our estimates when the software was created. Today, the moment 999 was breached, the program developed a bug and starting behaving abnormally. ....." :doh: :doh: :doh: When was the software created? In 666. :)

                      Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

                      Sander RosselS Offline
                      Sander RosselS Offline
                      Sander Rossel
                      wrote on last edited by
                      #19

                      There are cases where the opposite is also true... A table that will probably never get beyond a couple of 100's of records, but has a bigint as key :rolleyes:

                      It's an OO world.

                      public class Naerling : Lazy<Person>{}

                      V P 2 Replies Last reply
                      0
                      • P Pascal Ganaye

                        The sad thing is that it is one column in a 300 pages specification. The guy who do the specifications often do not have the technical expertise to know that a 16 bit integer can store 32000 values in 2 bytes. The programmer usually does, but the programmer is part of the chain. Every programmer is confronted to this problem at times. Do I raise the issue? If you raise the issue it will waste a few hours and you might end up finishing your development late. Also If you raise issues a bit too often you're quickly categorized as annoying git who can't follow orders. This is not the best way to progress in a company. I am not sure if this is true in India but this is true in the countries I worked in. If you shut up and follow orders, you won't get blamed and if you're on time you'll perhaps be promoted. The blame goes on the guy who did the specs despite the fact that the programmer is the best person to notice and fix the issue. To me this is the waterfall drama.

                        Sander RosselS Offline
                        Sander RosselS Offline
                        Sander Rossel
                        wrote on last edited by
                        #20

                        That is exactly how our database recently got some tables with ten columns of which seven were primary key (among which a varchar(50)). The tables were closely connected, but no foreign key was made anywhere. EVERY table (out of approximately 10) had the same redundant data stored along some other data unique to that table. All in all a true DB horror. The guy who made it is supposed to be our 'new' SQL expert, but simply followed the specs... :(( Luckily another programmer noticed and raised the issue to me. That's when I did not only raise the issue, but I raised hell as well! :-O Needless to say, the tables are being re-designed :-\

                        It's an OO world.

                        public class Naerling : Lazy<Person>{}

                        1 Reply Last reply
                        0
                        • A AspDotNetDev

                          Pascal Ganaye wrote:

                          The guy who do the specifications often do not have the technical expertise to know that a 16 bit integer can store 32000 values in 2 bytes

                          Ahem. 65,536 values.

                          Somebody in an online forum wrote:

                          INTJs never really joke. They make a point. The joke is just a gift wrapper.

                          P Offline
                          P Offline
                          Pascal Ganaye
                          wrote on last edited by
                          #21

                          Lol, you don't want to go negative!

                          1 Reply Last reply
                          0
                          • C Chris Meech

                            From the article, "We could not foresee that e-tickets would ever reach 1,000. This number was beyond all our estimates when the software was created. Today, the moment 999 was breached, the program developed a bug and starting behaving abnormally. ....." :doh: :doh: :doh: When was the software created? In 666. :)

                            Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

                            V Offline
                            V Offline
                            Vivi Chellappa
                            wrote on last edited by
                            #22

                            You have to understand the work culture in India. You as a programmer go into a meeting to discuss the Reservation System. The manager tells you not just what the requirements are but also how exactly it must be designed. If you don't follow his instructions to the letter (this assumes you actually have the ability to think for yourself, which is a rare commodity in Indian IT graduates) but deviate even slightly from what you are instructed to do, you will be forced to re-do it the manager's way. Any suggestions from you to improve usability will be turned down. Just go to the online reservation system for Indian Railways. To get from Chennai to Thiruvananthapuram (get Nishant to say it aloud so you know how to pronounce it :laugh: ), you have to know the station codes for both stations, and the train numbers of the various trains between the two stations. You have to backtrack from the reservations screen to a different screen to get the station code, to yet another screen to get all the train numbers which you must write down on paper so that you can input it when needed. The woes go on. We may use computers in India but we will make them as difficult as a face-to-face encounter at the ticket counter! Yes, at the ticket counter, they want you write the train numbers on the ticket rquest form too and you will have no computers to look them up!

                            H 1 Reply Last reply
                            0
                            • Sander RosselS Sander Rossel

                              There are cases where the opposite is also true... A table that will probably never get beyond a couple of 100's of records, but has a bigint as key :rolleyes:

                              It's an OO world.

                              public class Naerling : Lazy<Person>{}

                              V Offline
                              V Offline
                              Vivi Chellappa
                              wrote on last edited by
                              #23

                              The company I worked for in Silicon Valley never reached beyond 1,200 customers (including one-time customers who never came back), 400 items in its product line. It was a $1.2 billion company because they shipped millions of chips (just a few kind) costing a few dollars each. A Kraut came in as VP of IT and recommended they should install SAP. The company could have been run on a network of PCs except for the security concerns. It was on a virus-proof, hacker-proof IBM AS/400. The idiots reported the loss of $20 million in unusable software in their annual report. They could not implement the Manufacturing side of SAP as it was not designed for semiconductor manufacturing. The Kraut left within 3 months of arrival to become Senior VP of IT at the company he came from so he was never there to see the fruits of his recommendation. The company went down the drain and is a mere shadow of its old self now.

                              I 1 Reply Last reply
                              0
                              • B Bassam Abdul Baki

                                I could never understand why people only allow for 50% or 100% expansion. Always allow for 10 times even though you may never reach it. Yes, I know every bit counts, but better to lose a few bits than gain a bitch.

                                Web - BM - RSS - Math - LinkedIn

                                V Offline
                                V Offline
                                Vivi Chellappa
                                wrote on last edited by
                                #24

                                Every bit counted when your memory was limited to 4K and disk sizes were 5 MB. That gave us the Y2K problem. With 4GB of main memory and terabyte disks aplenty, there is NO reason at all today for this kind of design.

                                J K 2 Replies Last reply
                                0
                                • A AspDotNetDev

                                  Pascal Ganaye wrote:

                                  The guy who do the specifications often do not have the technical expertise to know that a 16 bit integer can store 32000 values in 2 bytes

                                  Ahem. 65,536 values.

                                  Somebody in an online forum wrote:

                                  INTJs never really joke. They make a point. The joke is just a gift wrapper.

                                  N Offline
                                  N Offline
                                  NedPat
                                  wrote on last edited by
                                  #25

                                  How do you get 1000 people sitting on a train?

                                  1 Reply Last reply
                                  0
                                  • N Nish Nishant

                                    http://articles.economictimes.indiatimes.com/2011-10-23/news/30313183_1_diwali-rush-western-railway-berths[^] TLDR : The IT company that designed the online reservation system for India's western railways used a 3-character field storing numbers to hold the reservation token (001 to 999) on a per-train basis. This limit was never ever hit until last week when (due to Diwali, an Indian festival) enough people made online bookings that the database crashed and with it the reservation system. Funny side-bit : 3 characters (even non-Unicode) is still larger than a short int (memory wise). So whoever did this pseudo-optimization was terribly ignorant.

                                    Regards, Nish


                                    My technology blog: voidnish.wordpress.com Part 2 in my WinRT/C++ series : Visual C++ and WinRT/Metro - Databinding Basics

                                    P Offline
                                    P Offline
                                    PSU Steve
                                    wrote on last edited by
                                    #26

                                    And how much of our IT has been outsourced to India? Heaven help us...

                                    1 Reply Last reply
                                    0
                                    • V Vivi Chellappa

                                      The company I worked for in Silicon Valley never reached beyond 1,200 customers (including one-time customers who never came back), 400 items in its product line. It was a $1.2 billion company because they shipped millions of chips (just a few kind) costing a few dollars each. A Kraut came in as VP of IT and recommended they should install SAP. The company could have been run on a network of PCs except for the security concerns. It was on a virus-proof, hacker-proof IBM AS/400. The idiots reported the loss of $20 million in unusable software in their annual report. They could not implement the Manufacturing side of SAP as it was not designed for semiconductor manufacturing. The Kraut left within 3 months of arrival to become Senior VP of IT at the company he came from so he was never there to see the fruits of his recommendation. The company went down the drain and is a mere shadow of its old self now.

                                      I Offline
                                      I Offline
                                      ii_noname_ii
                                      wrote on last edited by
                                      #27

                                      ..And the guy went back to working for SAP? (I always wondered how they sell that piece of scheisse! Good marketting, good lobbying, hopeless software, unrealistic costs... Oh, don't get me started on SAP!! lol)

                                      V 1 Reply Last reply
                                      0
                                      • N Nish Nishant

                                        http://articles.economictimes.indiatimes.com/2011-10-23/news/30313183_1_diwali-rush-western-railway-berths[^] TLDR : The IT company that designed the online reservation system for India's western railways used a 3-character field storing numbers to hold the reservation token (001 to 999) on a per-train basis. This limit was never ever hit until last week when (due to Diwali, an Indian festival) enough people made online bookings that the database crashed and with it the reservation system. Funny side-bit : 3 characters (even non-Unicode) is still larger than a short int (memory wise). So whoever did this pseudo-optimization was terribly ignorant.

                                        Regards, Nish


                                        My technology blog: voidnish.wordpress.com Part 2 in my WinRT/C++ series : Visual C++ and WinRT/Metro - Databinding Basics

                                        L Offline
                                        L Offline
                                        Lost User
                                        wrote on last edited by
                                        #28

                                        Which means those morons store the number in a string actually. God, stupidity is limitless.

                                        1 Reply Last reply
                                        0
                                        • A Andy Brummer

                                          From the US, I think the response would be they can fit 999 people on a train? :-D On the other side of the situation. The guy in charge of the India unique ID project gave a talk at the foundation where I work. That is a mind boggling huge project, and seem to be doing good planning to prevent these kinds of issues.

                                          Curvature of the Mind now with 3D

                                          N Offline
                                          N Offline
                                          NedPat
                                          wrote on last edited by
                                          #29

                                          I travel a lot, 999 is more than enough, block the thousandth and solve the problem.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups