php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62278 Data structure optimized for table data
Submitted: 2012-06-09 16:03 UTC Modified: 2021-06-18 09:10 UTC
From: jasonmoo at me dot com Assigned: cmb (profile)
Status: Wont fix Package: *Programming Data Structures
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
3 + 1 = ?
Subscribe to this entry?

 
 [2012-06-09 16:03 UTC] jasonmoo at me dot com
Description:
------------
Hey.  So it's not uncommon for a website to cache large database record sets in 
redis/memcache/etc and pull it out, filter it down, and present the remainder.  
However using an array of arrays has memory and speed disadvantages due to 
allocating more array buckets than needed and storing column names in every key 
of every row.


I'm requesting an SPL data structure that would reduce memory and increase 
access time on large record sets.

A recordset object could be initiated with an array of column names and optional 
row count.  Records could be added/removed but each row would be an arrayobject-
like object reflecting the column array.  However this object could store the 
data as a simple array and reference the recordset for a column's location in 
that array.

Initiating recordsets/records with counts gives the advantage of only allocating 
as much array buckets as needed.  And only storing the column names in the 
recordset object removes the need to store and hash each column name on each 
record.  

The memory savings on larger sets should be significant as well as a nice speed 
boost.  

If this was adopted, making it available as a native structure in the *sql 
drivers would reduce the overhead on actually getting it out of the database to 
begin with.  And a nice serialized format would reduce it's memory footprint in 
memcache/redis/etc as well.


This is my first submission for a feature request, while I've been a php dev for 
~12 years.  

Thanks!
Jason


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-09 21:53 UTC] cataphract@php.net
Something like this has a much better chance of landing if you write an implementation for it.
 [2021-06-18 09:10 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-06-18 09:10 UTC] cmb@php.net
This looks too special to me.  Declaring a class for the record
can be an alternative; otherwise Ds[1] may already provide the
needful.

If you stll feel that this would be a good feature addition,
please pursue the RFC process[2].

[1] <https://pecl.php.net/package/ds>
[2] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC