473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Big database: many SQL tables vs. object serialization

I'm building a PHP+MySQL application for a large website, with 100.000+
records in the main table, each one with a lot of dependencies in other
SQL tables. Thus each page view requires many SQL queries and/or joins.

Since I want to optimize performance, I'm wondering whether it would be
better to serialize full objects instead and store them in a single
table's TEXT field. This way I could just retrieve the row and
unserialize it, avoiding other queries. So far this is my comparison:

Pros:
- only one query per page view

Cons:
- not only a bigger database, due to serialization overhead, but a
single HUGE table (does this slow down things more than doing many
queries?)

Of course there are other drawbacks I actually don't care, such as
getting a very PHP-specific database or limiting retrival to IDs.

Does anybody have any advice about this? (Other than "try and benchmark
it" :->)

Alessandro.
Jul 17 '05 #1
3 3545
"Alessandro Ranellucci" <al**@primafila.net> wrote in message
news:al************************@powernews.iol.it.. .
: I'm building a PHP+MySQL application for a large website, with 100.000+
: records in the main table, each one with a lot of dependencies in other
: SQL tables. Thus each page view requires many SQL queries and/or joins.
:
: Since I want to optimize performance, I'm wondering whether it would be
: better to serialize full objects instead and store them in a single
: table's TEXT field. This way I could just retrieve the row and
: unserialize it, avoiding other queries. So far this is my comparison:

Well, I'd suggest looking at your database design first. It may well be
that if your data is in full 1NF, that denormalising it a *little* may
improve performance in terms of speed. Look at indices on joins, the types
of queries you're running, and the kind of data you're storing.
Jul 17 '05 #2
"Alessandro Ranellucci" <al**@primafila.net> wrote in message
news:al************************@powernews.iol.it.. .
I'm building a PHP+MySQL application for a large website, with 100.000+
records in the main table, each one with a lot of dependencies in other
SQL tables. Thus each page view requires many SQL queries and/or joins.

Since I want to optimize performance, I'm wondering whether it would be
better to serialize full objects instead and store them in a single
table's TEXT field. This way I could just retrieve the row and
unserialize it, avoiding other queries. So far this is my comparison:

Pros:
- only one query per page view

Cons:
- not only a bigger database, due to serialization overhead, but a
single HUGE table (does this slow down things more than doing many
queries?)

Of course there are other drawbacks I actually don't care, such as
getting a very PHP-specific database or limiting retrival to IDs.

Does anybody have any advice about this? (Other than "try and benchmark
it" :->)


Instead of the standard PHP serialization functions, use WDDX serialization.
Then you wouldn't have a PHP-specific database. More importantly, you can
claim to be in the forefront of technology with your "XML database" :-)

Jul 17 '05 #3
Alessandro Ranellucci wrote:

I'm building a PHP+MySQL application for a large website, with 100.000+
records in the main table, each one with a lot of dependencies in other
SQL tables. Thus each page view requires many SQL queries and/or joins.

Since I want to optimize performance, I'm wondering whether it would be
better to serialize full objects instead and store them in a single
table's TEXT field. This way I could just retrieve the row and
unserialize it, avoiding other queries. So far this is my comparison:

Pros:
- only one query per page view

Cons:
- not only a bigger database, due to serialization overhead, but a
single HUGE table (does this slow down things more than doing many
queries?)

Of course there are other drawbacks I actually don't care, such as
getting a very PHP-specific database or limiting retrival to IDs.

Does anybody have any advice about this? (Other than "try and benchmark
it" :->)

Alessandro.


Alessandro,

I'm with Matt on this one. Look at your database design and go from
there. The *correct* indicies will help performance (remember - you can
have too many indicies just as you can have too few).

But if you're going to serialize the object, why keep it in a database
at all? If you need this level of performance, put it in flat files and
create your own index structure. It will be much faster than anything
MySQL can do.

However, chances are you don't need this speed. After all, 100K rows
isn't very big at all. 100M rows is getting big; I've worked on
databases with 10G rows (not all one table).

If you can stuff everything into a single serialized object, then with
proper database design you should be able to retrieve everything from
the database with a single query.

--

To reply, delete the 'x' from my email
Jerry Stuckle,
JDS Computer Training Corp.
js*******@attglobal.net
Member of Independent Computer Consultants Association - www.icca.org
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dave Veeneman | last post by:
When does serializing objects make more sense than persisting them to a database? I'm new to object serialization, and I'm trying to get a feel for when to use it. Here is an example: I'm...
1
by: Roy Gourgi | last post by:
Hi, I am using VS.NET 2003 and I have made a connection to a MS Access database using the Server Explorer. Is this connection permanent, meaning that it will be there every time I reopen my...
0
by: Tommy Christian | last post by:
Hi! Anyone who knows about saving serialized data to database, coz I have a problem with that. If I just serialize my session data and then deserialize it, it works. But when I save it...
2
by: Marcel Balcarek | last post by:
Does anyone have an example of serializing an object to a database table?
5
by: Matthew | last post by:
I have a nice little Sub that saves data in a class "mySettings" to an XML file. I call it like so: Dim mySettings As mySettings = New mySettings mySettings.value1 = "someText" mySettings.value2...
4
by: Mark | last post by:
I'd like to take an instance of a class and store it in a database. I've marked my class as and am using the binary formatting code similar to...
1
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two...
0
by: XML newbie: Urgent pls help! | last post by:
I want to query the database located on the remote server(not on my network) based on the time frame and tables selected by the user in the GUI.I have created a reference to it's webservices. The...
1
by: | last post by:
Hi. This is a a semi-newbie question about how to store arbitrary information about my apps such that I can code quickly, mimizing complexity and the number of things I have to hold in my brain. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.