473,327 Members | 1,930 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,327 software developers and data experts.

Serializing data vs Storing it in a seperate table

What would give better performance, serializing a multidimensional array
and storing it in a single entry in a table or storing each element of
the array in a separate table and associating the entries with the entry
in the other table?

Having a separate table would result in two queries instead of one, but
you wouldn't have to deal with the overhead of serializing and
unserializing data.

-- Kyle
Jun 12 '06 #1
6 3144
Kyle Teague wrote:
What would give better performance, serializing a multidimensional array
and storing it in a single entry in a table or storing each element of
the array in a separate table and associating the entries with the entry
in the other table?

Having a separate table would result in two queries instead of one, but
you wouldn't have to deal with the overhead of serializing and
unserializing data.

-- Kyle


That depends. Is the multidimensional array a single entity - or is it a
collection of entities?

Do some research on "database normalization". It's almost never a good idea to
store multiple entities in a single field in a RDB.

BTW you can still do it with one query by joining tables.

One other thing - this isn't a PHP question - you should be asking in a group
related to your database, such as comp.databases.mysql.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 13 '06 #2
Jerry Stuckle wrote:
Kyle Teague wrote:
What would give better performance, serializing a multidimensional array
and storing it in a single entry in a table or storing each element of
the array in a separate table and associating the entries with the entry
in the other table?


That depends. Is the multidimensional array a single entity - or is it a
collection of entities?

Do some research on "database normalization". It's almost never a good
idea to store multiple entities in a single field in a RDB.

BTW you can still do it with one query by joining tables.

One other thing - this isn't a PHP question - you should be asking in a
group related to your database, such as comp.databases.mysql.


I don't think its OT. It really depends how big the array is and whether you
need all of it in memory every time you access it. If you only need a
specific element, I was surprised to find that even for quite small sets of
values the database was faster.

Build a test rig and try it out for yourself.

HTH

C.
Jun 16 '06 #3
Colin McKinnon wrote:
Jerry Stuckle wrote:

Kyle Teague wrote:
What would give better performance, serializing a multidimensional array
and storing it in a single entry in a table or storing each element of
the array in a separate table and associating the entries with the entry
in the other table?


That depends. Is the multidimensional array a single entity - or is it a
collection of entities?

Do some research on "database normalization". It's almost never a good
idea to store multiple entities in a single field in a RDB.

BTW you can still do it with one query by joining tables.

One other thing - this isn't a PHP question - you should be asking in a
group related to your database, such as comp.databases.mysql.

I don't think its OT. It really depends how big the array is and whether you
need all of it in memory every time you access it. If you only need a
specific element, I was surprised to find that even for quite small sets of
values the database was faster.

Build a test rig and try it out for yourself.

HTH

C.


Colin,

Look at the question again. He's asking about the method of storing data in a
database (database structure), not array handling.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 17 '06 #4
Jerry Stuckle (js*******@attglobal.net) wrote:
: Colin McKinnon wrote:
: > Jerry Stuckle wrote:
: >
: >
: >>Kyle Teague wrote:
: >>
: >>>What would give better performance, serializing a multidimensional array
: >>>and storing it in a single entry in a table or storing each element of
: >>>the array in a separate table and associating the entries with the entry
: >>>in the other table?
: >>>
: >>
: >>That depends. Is the multidimensional array a single entity - or is it a
: >>collection of entities?
: >>
: >>Do some research on "database normalization". It's almost never a good
: >>idea to store multiple entities in a single field in a RDB.
: >>
: >>BTW you can still do it with one query by joining tables.
: >>
: >>One other thing - this isn't a PHP question - you should be asking in a
: >>group related to your database, such as comp.databases.mysql.
: >>
: >
: >
: > I don't think its OT. It really depends how big the array is and whether you
: > need all of it in memory every time you access it. If you only need a
: > specific element, I was surprised to find that even for quite small sets of
: > values the database was faster.
: >
: > Build a test rig and try it out for yourself.
: >
: > HTH
: >
: > C.

: Colin,

: Look at the question again. He's asking about the method of storing data in a
: database (database structure), not array handling.

Look at the question again. He's asking about "serializing a
multidimensional array", which is php array handling.

In other words, he is asking whether it is better to implement his data
structure in php and use the database just as a blob-like storage medium,
or is it better to implement his data structure in the database and use
php just as an access method to get at the (already structured) data.

I would normally tend to towards defining the correct database structure
to hold the data. It will be more flexible in the long run, and you still
have the option of loading the data into a php data structure if you
really need to do that for speed in some situations.

Jun 17 '06 #5
Kyle Teague wrote:
What would give better performance, serializing a multidimensional array
and storing it in a single entry in a table or storing each element of
the array in a separate table and associating the entries with the entry
in the other table?

<snip>

That depends. If you store multi-dimensional array in a single
field by serializing, querying data (if based on the values present in
the array) will be difficult; so in that case, storing them in tables
will be a better choice.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jun 18 '06 #6
Malcolm Dew-Jones wrote:
Jerry Stuckle (js*******@attglobal.net) wrote:
: Colin McKinnon wrote:
: > Jerry Stuckle wrote:
: >
: >
: >>Kyle Teague wrote:
: >>
: >>>What would give better performance, serializing a multidimensional array
: >>>and storing it in a single entry in a table or storing each element of
: >>>the array in a separate table and associating the entries with the entry
: >>>in the other table?
: >>>
: >>
: >>That depends. Is the multidimensional array a single entity - or is it a
: >>collection of entities?
: >>
: >>Do some research on "database normalization". It's almost never a good
: >>idea to store multiple entities in a single field in a RDB.
: >>
: >>BTW you can still do it with one query by joining tables.
: >>
: >>One other thing - this isn't a PHP question - you should be asking in a
: >>group related to your database, such as comp.databases.mysql.
: >>
: >
: >
: > I don't think its OT. It really depends how big the array is and whether you
: > need all of it in memory every time you access it. If you only need a
: > specific element, I was surprised to find that even for quite small sets of
: > values the database was faster.
: >
: > Build a test rig and try it out for yourself.
: >
: > HTH
: >
: > C.

: Colin,

: Look at the question again. He's asking about the method of storing data in a
: database (database structure), not array handling.

Look at the question again. He's asking about "serializing a
multidimensional array", which is php array handling.

Yes - but only as it affects how to store it in the database. Without the
database the serialization is meaningless.
In other words, he is asking whether it is better to implement his data
structure in php and use the database just as a blob-like storage medium,
or is it better to implement his data structure in the database and use
php just as an access method to get at the (already structured) data.

Which is why he needs to be asking in the database newsgroup.
I would normally tend to towards defining the correct database structure
to hold the data. It will be more flexible in the long run, and you still
have the option of loading the data into a php data structure if you
really need to do that for speed in some situations.


It depends entirely on how he's going to use the data. Does he need to retrieve
all the data all the time? Or just bits and pieces of it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 18 '06 #7

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

Similar topics

16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
10
by: copx | last post by:
I want to save a struct to disk.... as plain text. At the moment I do it with a function that just writes the data using fprintf. I mean like this: fprintf(fp, "%d %d", my_struct.a, my_struct.b)...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
1
by: Martin Widmer | last post by:
Hi guys I am wondering what is a proper way to persistently store objects into SQL-Server. I see four possible ways: 1.) Serialize to XML and then store the XML in the SQL server 2.) Write a...
0
by: Kyle Teague | last post by:
What would give better performance, serializing a multidimensional array and storing it in a single entry in a table or storing each element of the array in a separate table and associating the...
47
by: Max | last post by:
Due to the behaviour of a particular COM object, I need to ensure that a request for a particular ASP page is finalized before another request for the page is processed. Does IIS have a way to...
3
by: Chris | last post by:
All I am cross-posting, as I'm not sure if this is an issue for the data layer or the application layer. If this is unacceptable, can someone let me know so that I don't do this in future. ...
4
by: buggtb | last post by:
This may be a blindingly obvious question but I am working on a little project and I'm relatively new to PHP. What I am wanting to do it load a load of data from an array into a table generated by...
1
by: webcm123 | last post by:
I'm looking for a good method of securing ratings. Cookies lock isn't sufficient. In addition to cookies I would need something else. I'm introducing some ways. -= Storing rates inside seperate...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.