Programming Theory
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesProgramming Theory

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old March 11th, 2004, 01:07 PM
danux danux is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 9 danux User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Database queries or arrays ?

Is it faster to put all data from databse to an array and make all changes using that array and at the end you update the database(i.e. you call only 2 times SQL when you retrieve data and when you put the new one on) ?
Or every time you want to make any changes you make them directly on the database (i.e. every time you call SQL)

10x for your time !

Reply With Quote
  #2  
Old March 11th, 2004, 01:21 PM
System System is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Posts: 665 System User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Message Moved

Thread moved from 'Database Help' to 'Programming Theory' by CodeKadiya.

Reason:

Reply With Quote
  #3  
Old March 11th, 2004, 02:32 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: Database queries or arrays ?

It depends. (It always depends.)

It's almost always faster to use as few database calls as possible, but you're probably going to run into some problems trying to update multiple rows with different data.

What data are you modifying?

Is each row modified by a person or is it a process? (A person is slow, so the speed of your database calls is much less important.)

Are you concerned about data changing in the database between when you read it and when you write it?

Reply With Quote
  #4  
Old March 12th, 2004, 10:50 AM
danux danux is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 9 danux User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: RE: Database queries or arrays ?

Thanks for your post.
Quote:
What data are you modifying?

It's about the administration of a small CMS, so the data is one table that contains all articles.
Quote:
Is each row modified by a person or is it a process? (A person is slow, so the speed of your database calls is much less important.)

Each row is modified by the admin user.
Quote:
Are you concerned about data changing in the database between when you read it and when you write it?

I'll change database only when I'm writing.

It'a question of performence. Is it beter when the admin user logs in the system to put all the data in the memory, or only when he wants to modify some data to retrieve this one from SQL ?
Less SQL calls is better, using memory ,or put the minimum vars in memory and every time when the admin decides to edit some data retrieve it form SQL-much SQL calls.

Thanks for your time !


Reply With Quote
  #5  
Old March 12th, 2004, 11:30 AM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 7 m 51 sec
Reputation Power: 4
RE: Database queries or arrays ?

If I were to do this, I would call just the needed data out of the database. Since it is a content management system, my thought would be that it would take longer to process if you pulled all the articles out and then did your processing, rather than just pulling the selected ones you want out and then processing.

Reply With Quote
  #6  
Old March 12th, 2004, 11:48 AM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: Database queries or arrays ?

I'd suggest querying as little data as possible in as few querys as possible - of course, don't do less than you need.

I wouldn't worry about taking up too much system memory unless the content you're talking about is on the order of megs of data.

Reply With Quote
  #7  
Old March 12th, 2004, 12:00 PM
danux danux is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 9 danux User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Database queries or arrays ?

Thanks all of you, I think you're right it's better to retrieve only the needed vars for reading, and if the admin wants to edit some content retrieve from db only that article!


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesProgramming Theory > Database queries or arrays ?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway