473,699 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Poll's options - two queries to MySQL or Unserialize()?

I'm making some changes in poll module. I don't know which method of
storing options of poll is better. The main data of polls are in POLLS
table.

Speed and efficiency is the most important issue. There are 2 methods:

1. Storing options in ANSWERS table and executing 2 queries to get
poll's data and options. Number of records connected with a poll in
that table is equal to number of poll's options.

Fields in ANSWERS table:
Poll ID | Sequence (optional) | Option | Amount of votes

2. Storing options in another field in POLLS table. They would be
being unserialized after getting data from database. Perhaps, it's
faster method.

Tests of serialize() and unserialize():
Seconds: 0.000138 | 9.5E-005
Miliseconds: 0.122 | 0.095

What do you think about it? Which method should I use?

May 23 '07 #1
2 2496
On 23.05.2007 15:52 we******@gmail. com wrote:
I'm making some changes in poll module. I don't know which method of
storing options of poll is better. The main data of polls are in POLLS
table.

Speed and efficiency is the most important issue.
Nope. Clean code and maintainability is always more important (unless
you're making software for ballistic missile navigation). ;)

From this point of view, database solution looks better.
>
1. Storing options in ANSWERS table and executing 2 queries to get
poll's data and options. Number of records connected with a poll in
that table is equal to number of poll's options.

Fields in ANSWERS table:
Poll ID | Sequence (optional) | Option | Amount of votes

2. Storing options in another field in POLLS table. They would be
being unserialized after getting data from database. Perhaps, it's
faster method.

Tests of serialize() and unserialize():
Seconds: 0.000138 | 9.5E-005
Miliseconds: 0.122 | 0.095

What do you think about it? Which method should I use?

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
May 23 '07 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

we******@gmail. com wrote:
I'm making some changes in poll module. I don't know which method of
storing options of poll is better. The main data of polls are in POLLS
table. [snip]
Serialize and unserialize are extremely fast, so if you don't mind
breaking the rules of database normalization and stuff multiple values
in one column, your second option will be faster.

- --
Edward Z. Yang GnuPG: 0x869C48DA
HTML Purifier <htmlpurifier.o rg Anti-XSS HTML Filter
[[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGVLrBqTO +fYacSNoRApCIAJ oCBo/NrAAkgpOl68xxV+ L4Tm5onQCeOYWb
kNEGzWnAzf/Jjg2eSVE5A6A=
=I5+3
-----END PGP SIGNATURE-----
May 23 '07 #3

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

Similar topics

3
8123
by: Mark | last post by:
Greetings: So, I've got a real problem in that PHP doesn't seem to be able to unserialize() an array that has an element containing a newline. Of course, I've used htmlentities() to protect the serialized data. Here's a simple example that demonstrates the problem: ----- <?php
7
5139
by: richbl | last post by:
Hello all, I have a question about unserializing a single array element from a serialized array. Can this be done, or must I first unserialize the array, and then access the element? For example, given: $data = serialize(array('4.50','0.00','0.00'));
17
1986
by: Doug Holton | last post by:
George W Bush, as certified by Florida's election commission. Which decorator syntax do you like the most? See http://wiki.wxpython.org/index.cgi/PythonDecoratorsPoll A. @classmethod def foo(): (82) 14% C1. def foo() : (235) 41% E1. def foo(): @classmethod (260) 45% Total Votes: 577
28
2381
by: Paul McGuire | last post by:
Well, after 3 days of open polling, the number of additional votes have dropped off pretty dramatically. Here are the results so far: Total voters: 55 (with 3 votes each) Votes for each choice or group of choices: Any J 81 J2 78 Any C 40 C1 29 Any D 9
4
3068
by: Bee | last post by:
Hi everyone, I'm having trouble accessing a Mysql database containing checkbox data that is posted from a form. I use the serialize function to store the checkbox values in an array (in a column called "CHECKBOX"). Each row in the table has this format: a:2:{i:0;s:7:"Peanuts";i:1;s:9:"Cows_milk";}
15
6847
by: dixie | last post by:
I have a command to open the Access Options dialogue from code: DoCmd.RunCommand acCmdOptions It also opens the Database Window behind it. Is it possible to open the Options without having the database window open as well? dixie
5
3763
by: Mike | last post by:
I finally got serialize to work but now I cannot get unserialize to work. Here is my code. $settings = serialize($settings_array); echo "<INPUT TYPE='Hidden' NAME='settings' VALUE='".$settings."'>"; $settings = $_REQUEST; echo "<P>us=".$settings; $settings_array = Array();
7
2720
by: Daz | last post by:
Hi. I am trying to select data from two separate MySQL tables, where I cannot use join, but when I put the two select queries into a single query, I get an error telling me to check my syntax. Both of the queries work fine when I use them to query the MySQL server directly. My guess is that the MySQL extension only expects a single resource back from the database, but get's several, or that it just checks the statement first, and decides...
10
1817
by: Jerim | last post by:
I am attempting to put together one script that pulls data from one database on its own server, and data from another database on its own server, which is off-site. Server 1 - Only allows shared memory access to the database. Also disallows http:// includes. This is where the database of names is stored. This is our internal MySQL server. Server 2 - Only allows shared memory access to the database. So anything that calls the...
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9171
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.