Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Efficiently Walking Large Data Structures Stored in Multiple Tables

by kvale (Monsignor)
on Feb 28, 2004 at 15:34 UTC ( [id://332479]=note: print w/replies, xml ) Need Help??


in reply to Efficiently Walking Large Data Structures Stored Across Multiple Tables

It sounds like your production app is slowing down due to the all the database accesses to find the next page, so what you want to do is minimize those.

You can think of progressing through the cirriculum as a sequential walk through the records, which makes me think of a linked list. So a simple solution is to add a column to your db that gives the location of the next page 'next_page_ID' (assuming that you have a pages table in which each page has a unique ID). Then finding the next page has no extra lookups or tricky hash walking--everything has been precomputed beforehand.

-Mark

  • Comment on Re: Efficiently Walking Large Data Structures Stored in Multiple Tables

Replies are listed 'Best First'.
Re: Re: Efficiently Walking Large Data Structures Stored in Multiple Tables
by jerrygarciuh (Curate) on Feb 28, 2004 at 15:40 UTC
    Mark,
    That is a great idea! I can make the curriculum admin wizard do the heavy lifting as the items are being added/reordered.
    Thanks! Off to work on it...
    jg
    _____________________________________________________
    "The man who grasps principles can successfully select his own methods.
    The man who tries methods, ignoring principles, is sure to have trouble.
    ~ Ralph Waldo Emerson
        whilst recursive queries are fun, as you can do a whole lot of lookups and join them together in one sql statement; they do take a long time to run, significantly degrading performance. The flatter you can make the structure of the database, especially the often used tables, the faster the retrieval -- unfortunatelly this also means you end up with extra effort in maintaining the tables, as they start having redundant data (not fully normalised).
        If you're dealing with a database that can handle tree structures natively, maybe. But, I read the articles on doing tree structures as sets and I was ... underwhelmed. If all you need is the next page and there is only ever one next page, then deal with it that way. If you need a true parent-child structure and a way of asking for all parents without wanting to explicitly code it into your SQL and have it handled correctly by the optimizer ... good luck without Oracle or PostgreSQL.

        Now, you could build the queries using some module (???), but the queries are very very very slow and very very very difficult to get right. Again, good luck. I wouldn't want to try ...

        ------
        We are the carpenters and bricklayers of the Information Age.

        Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://332479]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found