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. General Programming
  3. C / C++ / MFC
  4. Concept/example for virtual list

Concept/example for virtual list

Scheduled Pinned Locked Moved C / C++ / MFC
databasequestionperformancehelptutorial
11 Posts 4 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 Offline
    N Offline
    nobaq
    wrote on last edited by
    #1

    Hi, I need to display ~ 100000 entries in a windows list which are stored in an SQL database (queried by a SELECT query with a few JOINs). 1st question: In only need to display a simple list. I would really like to use a Listbox Control for the sake of simplicity. Do I really need to choose a (complex) List Control? 2nd question: I tried a virtual list with a simple SQL query:

    OnInitDialog()
    ...
    // SELECT COUNT(*) FROM...
    m_ctrlWords.SetItemCountEx(count);
    ....

    OnLvnGetdispinfoWords(...)
    ...
    sql.Format("SELECT keywordID, keyword FROM keywords ORDER BY keyword LIMIT %d, 1", index);
    // query
    const char *res = query.getStringField("keyword");
    lstrcpy(pItem->pszText, res);

    but this is really too slow. I think I need OnLvnOdcachehintWords but it's somehow complicated. I could not find any concepts (which data structure to choose??) or examples concerning this :-( The problem is that I have to remove old entried in cache (or my app's memory consumption would explode). Does anyone have implemented such a virtual list (with data in SQL) already? Are there some examples or concepts available? Thank you very much, Niki

    S D M 3 Replies Last reply
    0
    • N nobaq

      Hi, I need to display ~ 100000 entries in a windows list which are stored in an SQL database (queried by a SELECT query with a few JOINs). 1st question: In only need to display a simple list. I would really like to use a Listbox Control for the sake of simplicity. Do I really need to choose a (complex) List Control? 2nd question: I tried a virtual list with a simple SQL query:

      OnInitDialog()
      ...
      // SELECT COUNT(*) FROM...
      m_ctrlWords.SetItemCountEx(count);
      ....

      OnLvnGetdispinfoWords(...)
      ...
      sql.Format("SELECT keywordID, keyword FROM keywords ORDER BY keyword LIMIT %d, 1", index);
      // query
      const char *res = query.getStringField("keyword");
      lstrcpy(pItem->pszText, res);

      but this is really too slow. I think I need OnLvnOdcachehintWords but it's somehow complicated. I could not find any concepts (which data structure to choose??) or examples concerning this :-( The problem is that I have to remove old entried in cache (or my app's memory consumption would explode). Does anyone have implemented such a virtual list (with data in SQL) already? Are there some examples or concepts available? Thank you very much, Niki

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      You'll probably be better off executing something like "SELECT keywordID, keyword FROM keywords ORDER BY keyword" within OnInitDialog and caching the results in a resultset or whatever equivalent your database interface technology offers. Then you can interrogate the cache within OnLvnGetdispinfoWords and don't need to bother with OnLvnOdcachehintWords.

      N 1 Reply Last reply
      0
      • N nobaq

        Hi, I need to display ~ 100000 entries in a windows list which are stored in an SQL database (queried by a SELECT query with a few JOINs). 1st question: In only need to display a simple list. I would really like to use a Listbox Control for the sake of simplicity. Do I really need to choose a (complex) List Control? 2nd question: I tried a virtual list with a simple SQL query:

        OnInitDialog()
        ...
        // SELECT COUNT(*) FROM...
        m_ctrlWords.SetItemCountEx(count);
        ....

        OnLvnGetdispinfoWords(...)
        ...
        sql.Format("SELECT keywordID, keyword FROM keywords ORDER BY keyword LIMIT %d, 1", index);
        // query
        const char *res = query.getStringField("keyword");
        lstrcpy(pItem->pszText, res);

        but this is really too slow. I think I need OnLvnOdcachehintWords but it's somehow complicated. I could not find any concepts (which data structure to choose??) or examples concerning this :-( The problem is that I have to remove old entried in cache (or my app's memory consumption would explode). Does anyone have implemented such a virtual list (with data in SQL) already? Are there some examples or concepts available? Thank you very much, Niki

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        nobaq wrote:

        I need to display ~ 100000 entries in a windows list...

        Why? Who would want to navigate through such a list?

        "Love people and use things, not love things and use people." - Unknown

        "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

        N 1 Reply Last reply
        0
        • S Stuart Dootson

          You'll probably be better off executing something like "SELECT keywordID, keyword FROM keywords ORDER BY keyword" within OnInitDialog and caching the results in a resultset or whatever equivalent your database interface technology offers. Then you can interrogate the cache within OnLvnGetdispinfoWords and don't need to bother with OnLvnOdcachehintWords.

          N Offline
          N Offline
          nobaq
          wrote on last edited by
          #4

          Hello, I have to correct: The entries are much more than 100000...it's a fulltext recherche of a huge database system. So it's definitifely too large to just read out all entries and cache them. Regards, Niki

          N S 2 Replies Last reply
          0
          • N nobaq

            Hi, I need to display ~ 100000 entries in a windows list which are stored in an SQL database (queried by a SELECT query with a few JOINs). 1st question: In only need to display a simple list. I would really like to use a Listbox Control for the sake of simplicity. Do I really need to choose a (complex) List Control? 2nd question: I tried a virtual list with a simple SQL query:

            OnInitDialog()
            ...
            // SELECT COUNT(*) FROM...
            m_ctrlWords.SetItemCountEx(count);
            ....

            OnLvnGetdispinfoWords(...)
            ...
            sql.Format("SELECT keywordID, keyword FROM keywords ORDER BY keyword LIMIT %d, 1", index);
            // query
            const char *res = query.getStringField("keyword");
            lstrcpy(pItem->pszText, res);

            but this is really too slow. I think I need OnLvnOdcachehintWords but it's somehow complicated. I could not find any concepts (which data structure to choose??) or examples concerning this :-( The problem is that I have to remove old entried in cache (or my app's memory consumption would explode). Does anyone have implemented such a virtual list (with data in SQL) already? Are there some examples or concepts available? Thank you very much, Niki

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            Use a CListBox,in virtual mode. If I remember correctly, You will need to manually draw and manage the data, but it will make the CListBox very fast; once you know how to do it, you will use it everywhere. You will need to override the CListBox::DrawItem (and maybe the CListBox::MeasureItem )

            N 1 Reply Last reply
            0
            • D David Crow

              nobaq wrote:

              I need to display ~ 100000 entries in a windows list...

              Why? Who would want to navigate through such a list?

              "Love people and use things, not love things and use people." - Unknown

              "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

              N Offline
              N Offline
              nobaq
              wrote on last edited by
              #6

              Just look at winhelp32 fulltext- or keyword search. This is exactly what I want to implement. Regards, Niki

              1 Reply Last reply
              0
              • N nobaq

                Hello, I have to correct: The entries are much more than 100000...it's a fulltext recherche of a huge database system. So it's definitifely too large to just read out all entries and cache them. Regards, Niki

                N Offline
                N Offline
                nobaq
                wrote on last edited by
                #7

                I have tried it using caching and virtual list controls. Even if I read only the elements from LVN_ODCACHEHINT and cache them into a map, the list is really, really tooo slow. What could be the solution? I just want to have the same as WinHelp32's keyword (or topic) search. For some reason, this list is very very fast since over 10 years (with slow computers). Regards, Niki

                S 2 Replies Last reply
                0
                • M Maximilien

                  Use a CListBox,in virtual mode. If I remember correctly, You will need to manually draw and manage the data, but it will make the CListBox very fast; once you know how to do it, you will use it everywhere. You will need to override the CListBox::DrawItem (and maybe the CListBox::MeasureItem )

                  N Offline
                  N Offline
                  nobaq
                  wrote on last edited by
                  #8

                  Hi, thank you for this hint. I've been searching for a while now but I can not find any docs Do you have a reference, docs, howtos for subclassing CListBox in order to implement a virtual listbox? Any anyway, how do I query data from my database when "scrolling" very fast? I think i need to minimze my database queries but on the other hand I need to display something while scrolling... Regards, Niki

                  1 Reply Last reply
                  0
                  • N nobaq

                    Hello, I have to correct: The entries are much more than 100000...it's a fulltext recherche of a huge database system. So it's definitifely too large to just read out all entries and cache them. Regards, Niki

                    S Offline
                    S Offline
                    Stuart Dootson
                    wrote on last edited by
                    #9

                    OK - in that case, you want to cache maybe a couple of hundred rows starting at the row that's at the top of the list control. Then, as users move down the list, you can retrieve a few hundred rows at intervals, when required?

                    1 Reply Last reply
                    0
                    • N nobaq

                      I have tried it using caching and virtual list controls. Even if I read only the elements from LVN_ODCACHEHINT and cache them into a map, the list is really, really tooo slow. What could be the solution? I just want to have the same as WinHelp32's keyword (or topic) search. For some reason, this list is very very fast since over 10 years (with slow computers). Regards, Niki

                      S Offline
                      S Offline
                      Stuart Dootson
                      wrote on last edited by
                      #10

                      nobaq wrote:

                      I have tried it using caching and virtual list controls. Even if I read only the elements from LVN_ODCACHEHINT and cache them into a map, the list is really, really tooo slow.

                      I'm surprised - I've implemented virtual lists that provide views over 10s of thousands of rows (and 10s of columns) of data - they've been as quick as you could want. I feel sure you're using the right technology (virtual list controls) but there's something not quite right about your implementation?

                      1 Reply Last reply
                      0
                      • N nobaq

                        I have tried it using caching and virtual list controls. Even if I read only the elements from LVN_ODCACHEHINT and cache them into a map, the list is really, really tooo slow. What could be the solution? I just want to have the same as WinHelp32's keyword (or topic) search. For some reason, this list is very very fast since over 10 years (with slow computers). Regards, Niki

                        S Offline
                        S Offline
                        Stuart Dootson
                        wrote on last edited by
                        #11

                        One other thing - have you profiled the code to see what is slowing it down? I'd suggest implementing a virtual list control that just displays the numeric index of the list rows, to convince yourself that you've got the virtual list control set up correctly. Then work out how much of the SQL query you can do without taking too much time, and you can try to merge that into the list control implementation?

                        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