vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello, I am working on a personnel registry that has upwards of 50,000 registrants. Currently I am working on an export module that will create a CSV from multiple tables. I have managed to keep the script (PHP) under the memory limit when creating and inserting the CSV into the database. The problem comes when I try to query for the data and export it. Memory limit is a major concern, but the query for one row returns a result set too large and PHP fails. I've thought about storing the data in multiple rows and then querying one-by-one and outputting, but was hoping there was a better way. Thanks in advance for the help. MG Mike Ginsburg Collaborative Fusion, Inc. mginsburg@collaborativefusion.com 412-422-3463 x4015 ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| |||
| Mike Ginsburg escreveu: > Hello, > I am working on a personnel registry that has upwards of 50,000 > registrants. Currently I am working on an export module that will > create a CSV from multiple tables. I have managed to keep the script > (PHP) under the memory limit okay... some info needed here. 1. memory on the DB server 2. memory_limit on php.ini > when creating and inserting the CSV into the database. The problem > comes when I try to query for the data and export it. Memory limit is > a major concern, but the query for one row returns a result set too > large and PHP fails. a single row is enough to crash PHP ? > > I've thought about storing the data in multiple rows and then querying > one-by-one and outputting, but was hoping there was a better way. if you canīt raise memory_limit, I think itīs the only way. []īs ACV ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| |||
| André Volpato wrote: > Mike Ginsburg escreveu: >> Hello, >> I am working on a personnel registry that has upwards of 50,000 >> registrants. Currently I am working on an export module that will >> create a CSV from multiple tables. I have managed to keep the script >> (PHP) under the memory limit > okay... some info needed here. > 1. memory on the DB server > 2. memory_limit on php.ini PHP Memory Limit is 16M. We're running multiple installations on a single webserver, so memory is a concern DB Server is separate from the webserver. >> when creating and inserting the CSV into the database. The problem >> comes when I try to query for the data and export it. Memory limit >> is a major concern, but the query for one row returns a result set >> too large and PHP fails. > a single row is enough to crash PHP ? Well the "data" field in the table (text) contains 50K lines. It's over 30M in size for the full export. > >> >> I've thought about storing the data in multiple rows and then >> querying one-by-one and outputting, but was hoping there was a better >> way. > if you canīt raise memory_limit, I think itīs the only way. I was afraid that would be the answer. > > []īs > ACV > > > > > > > Mike Ginsburg Collaborative Fusion, Inc. mginsburg@collaborativefusion.com 412-422-3463 x4015 ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend |
| |||
| Mike Ginsburg wrote: > Hello, > I am working on a personnel registry that has upwards of 50,000 > registrants. Currently I am working on an export module that will create a > CSV from multiple tables. I have managed to keep the script (PHP) under > the memory limit when creating and inserting the CSV into the database. > The problem comes when I try to query for the data and export it. Memory > limit is a major concern, but the query for one row returns a result set > too large and PHP fails. One row? Wow, I didn't know PHP was that broken. Try declaring a cursor and fetching a few rows at a time. -- Alvaro Herrera http://www.PlanetPostgreSQL.org/ "No es bueno caminar con un hombre muerto" ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| |||
| Mike Ginsburg escreveu: > André Volpato wrote: >> Mike Ginsburg escreveu: >>> Hello, >>> I am working on a personnel registry that has upwards of 50,000 >>> registrants. Currently I am working on an export module that will >>> create a CSV from multiple tables. I have managed to keep the >>> script (PHP) under the memory limit >> okay... some info needed here. >> 1. memory on the DB server >> 2. memory_limit on php.ini > PHP Memory Limit is 16M. We're running multiple installations on a > single webserver, so memory is a concern > DB Server is separate from the webserver. >>> when creating and inserting the CSV into the database. The problem >>> comes when I try to query for the data and export it. Memory limit >>> is a major concern, but the query for one row returns a result set >>> too large and PHP fails. >> a single row is enough to crash PHP ? > Well the "data" field in the table (text) contains 50K lines. It's > over 30M in size for the full export. >> >>> >>> I've thought about storing the data in multiple rows and then >>> querying one-by-one and outputting, but was hoping there was a >>> better way. >> if you canīt raise memory_limit, I think itīs the only way. > I was afraid that would be the answer. Well, you could try to retrieve data with substr(), say 10k lines in 5 queries. Itīs kinda ugly, but should work in this case... []īs ACV ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |
| |||
| On 10/4/07, Alvaro Herrera <alvherre@commandprompt.com> wrote: > Mike Ginsburg wrote: > > Hello, > > I am working on a personnel registry that has upwards of 50,000 > > registrants. Currently I am working on an export module that will create a > > CSV from multiple tables. I have managed to keep the script (PHP) under > > the memory limit when creating and inserting the CSV into the database. > > The problem comes when I try to query for the data and export it. Memory > > limit is a major concern, but the query for one row returns a result set > > too large and PHP fails. > > One row? Wow, I didn't know PHP was that broken. No, it's not php, it's his approach that's broken. He was saying that a single db row has a text column with 50,000 lines. The fact that php throws and error and stop rather than running your machine out of memory would hardly qualify as broken. It's got a memory limit for a reason. Even Java I believe has one. ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq |
| |||
| Alvaro Herrera escreveu: Mike Ginsburg wrote: Hello, I am working on a personnel registry that has upwards of 50,000 registrants. Currently I am working on an export module that will create a CSV from multiple tables. I have managed to keep the script (PHP) under the memory limit when creating and inserting the CSV into the database. The problem comes when I try to query for the data and export it. Memory limit is a major concern, but the query for one row returns a result set too large and PHP fails. One row? Wow, I didn't know PHP was that broken. Try declaring a cursor and fetching a few rows at a time. PHP is just respecting memory_limit when retrieving data. In this case, a single row is about 30M, a lot more than the limit of 16M. I think cursors wouldn´t help anyway. []´s, ACV |
| |||
| Scott Marlowe escribió: > On 10/4/07, Alvaro Herrera <alvherre@commandprompt.com> wrote: > > Mike Ginsburg wrote: > > > Hello, > > > I am working on a personnel registry that has upwards of 50,000 > > > registrants. Currently I am working on an export module that will create a > > > CSV from multiple tables. I have managed to keep the script (PHP) under > > > the memory limit when creating and inserting the CSV into the database. > > > The problem comes when I try to query for the data and export it. Memory > > > limit is a major concern, but the query for one row returns a result set > > > too large and PHP fails. > > > > One row? Wow, I didn't know PHP was that broken. > > No, it's not php, it's his approach that's broken. Oh, I didn't realize that's what he was saying. Of course, you can get the thing out of the database using substring() but really this is a matter of really poor design. -- Alvaro Herrera http://www.amazon.com/gp/registry/CTMLCN8V17R4 "No hay cielo posible sin hundir nuestras raíces en la profundidad de la tierra" (Malucha Pinto) ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| |||
| On 10/4/07, Mike Ginsburg <mginsburg@collaborativefusion.com> wrote: > export it. Memory limit is a major concern, but the query for one row > returns a result set too large and PHP fails. If this is true, and one single db row makes php exceed its memory limit just by returning it, you've done something very very in your design. You'd proably be better served using either a plain text file system to store these things, or large objects in postgresql. But if you're stuffing ~8 megs worth of csv text data into a single row* you're probably not using a very relational layout of your data. And you're losing all the advantages (checking your data for consistency and such) that a relational db could give you. * Note that I'm assuming a few things up there. 1: php uses about 2:1 memory to store data it's holding, roughly. If you're set to 16 Meg max, I'm assuming your return set is 8Meg or larger. ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org/ |
| ||||
| Scott Marlowe wrote: > On 10/4/07, Mike Ginsburg <mginsburg@collaborativefusion.com> wrote: > > >> export it. Memory limit is a major concern, but the query for one row >> returns a result set too large and PHP fails. >> > > If this is true, and one single db row makes php exceed its memory > limit just by returning it, you've done something very very in your > design. > This is for the export only. Since it is an export of ~50,000 registrants, it takes some time to process. We also have load balanced web servers, so unless I want to create identical processes on all webservers, or write some crazy script to scp it across the board, storing it as a text file is not an option. I realize that my way of doing it is flawed, which the reason I came here for advice. The CSV contains data from approximately 15 tables, several of which are many-to-ones making joins a little tricky. My thought was to do all of the processing in the background, store the results in the DB, and allowing the requester to download it at their convenience. Would it be a good idea to create a temporary table that stored all of the export data in it broken out by rows and columns, and when download time comes, query from their? > You'd proably be better served using either a plain text file system > to store these things, or large objects in postgresql. > > But if you're stuffing ~8 megs worth of csv text data into a single > row* you're probably not using a very relational layout of your data. > And you're losing all the advantages (checking your data for > consistency and such) that a relational db could give you. > > * Note that I'm assuming a few things up there. 1: php uses about 2:1 > memory to store data it's holding, roughly. If you're set to 16 Meg > max, I'm assuming your return set is 8Meg or larger. > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org/ > > > > > > > Mike Ginsburg Collaborative Fusion, Inc. mginsburg@collaborativefusion.com 412-422-3463 x4015 |