/    Sign up×
Community /Pin to ProfileBookmark

All at once or bit by bit?

I have to insert loads of data at a time in a mysql table (like 4000-9000 rows at a time). What’s the best way to do this? I can make a huuuge query and insert everything with that, or i can make a LOT of small queries for each row… What’s better?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@JDM71488Aug 22.2007 — i don't see why you couldn't try all 4000-9000 the first time as a test, see how the server handles it, and figure out if you need to break it up.
Copy linkTweet thisAlerts:
@ZnupiauthorAug 22.2007 — Well that's what I did and it works for ~5000 rows (I can't test with more, I don't have the data now, I'm still working on the project). The server handles it remarkably well: it runs the query in under 1 second ?. And right now this runs on localhost which is my desktop computer and runs many apps... from firefox to beryl. When the site will be up it will run on a proper server.

Thing is, it will probably run 100 queries like this one after another, and on my localhost it gave a 'memory limit exceeded' error once when I was only running a couple of big queries so I had to use
[code=php]ini_set("memory_limit", "-1");[/code]

...So, would inserting it bit by bit be easier on the machine? Memory, CPU, etc...?
Copy linkTweet thisAlerts:
@pcthugAug 23.2007 — [url=http://au3.php.net/mysqli_prepare]Prepared[/url] Queries would be your best bet.
×

Success!

Help @Znupi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...