Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Query or Array functions
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  17 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Scott Johnson  
View profile  
 More options Feb 9, 8:18 pm
Newsgroups: comp.lang.php
From: Scott Johnson <nooneh...@chalupasworld.com>
Date: Thu, 09 Feb 2012 17:18:46 -0800
Local: Thurs, Feb 9 2012 8:18 pm
Subject: Query or Array functions
OK I will try to ask this and make sense out of this also.

First off I am doing this on a back-end admin page.
I have a DB with lets say 5000 records and a dozen or more fields.

On the page which will display these records I am planning on using
pagination to display so many records at once.  So far so good.

What i would like to do is provide a row above the table of records
where the user can enter text to filter the display on each column.

I plan to use AJAX and filter as the user types which in itself is not a
problem.

The problem I see is the numerous DB queries and I don't see querying
the DB each time the user types a letter as a practical approach. (I
could be wrong).

What I was thinking of doing is loading the full record set into an
array and then filter out the array of the needed data as the user types.

I have not done any intense array manipulations like this before and am
wondering if this seems like a practical approach.

I would like to ask for any advice or suggestions on this.  I may even
have my head in the wrong area and not see the forest thru the trees.

Thanks
Scotty


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Fesser  
View profile  
 More options Feb 9, 8:39 pm
Newsgroups: comp.lang.php
From: Michael Fesser <neti...@gmx.de>
Date: Fri, 10 Feb 2012 02:39:30 +0100
Local: Thurs, Feb 9 2012 8:39 pm
Subject: Re: Query or Array functions
.oO(Scott Johnson)

>First off I am doing this on a back-end admin page.
>I have a DB with lets say 5000 records and a dozen or more fields.

>On the page which will display these records I am planning on using
>pagination to display so many records at once.  So far so good.

>What i would like to do is provide a row above the table of records
>where the user can enter text to filter the display on each column.

>I plan to use AJAX and filter as the user types which in itself is not a
>problem.

Why AJAX? Why not do it the simple way with a "refresh" button?

>The problem I see is the numerous DB queries and I don't see querying
>the DB each time the user types a letter as a practical approach. (I
>could be wrong).

>What I was thinking of doing is loading the full record set into an
>array and then filter out the array of the needed data as the user types.

>I have not done any intense array manipulations like this before and am
>wondering if this seems like a practical approach.

I don't think so. You still have to fetch the data from the DB whenever
the user changes the filter. Every AJAX request to the server is just
another HTTP request, completely independent from all others before.

You can't store big data from one request and then just output parts of
it on every coming request (unless you store all the data in a session,
but this wouldn't make much sense here and would still cause a lot of IO
overhead).

In other words: Every request (including the ones via AJAX) causes your
script to start from scratch again, so you have to fetch the data and
filter it over and over again anyway. Also don't forget that after the
user changes the filter options, the new data has to be transferred to
the client. When there's a lot of records, this might take some time.

Don't expect a real-time display and ask yourself: Do you really need
AJAX stuff or wouldn't it be enough to use a good old-fashioned form
with a "refresh" button?

Micha

--
http://mfesser.de/blickwinkel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Álvaro G. Vicario  
View profile  
 More options Feb 10, 3:26 am
Newsgroups: comp.lang.php
From: "Álvaro G. Vicario" <alvaro.NOSPAMTH...@demogracia.com.invalid>
Date: Fri, 10 Feb 2012 09:26:21 +0100
Local: Fri, Feb 10 2012 3:26 am
Subject: Re: Query or Array functions
El 10/02/2012 2:18, Scott Johnson escribió/wrote:

If you are worried about retrieving matching rows from a 5000 row DB
table using a SQL query, I doubt that using a file to store a serialized
5000 element bi-dimensional array and looping though it to find matches
will be faster; not to mention the mess of keeping data up-to-date and
taking care of concurrent access.

A 10,000,000 record table is a big table. A 5,000 record table is not.
Just make sure that your SQL knowledge goes beyond "SELECT * FROM foo".
I've seen too many amateurs in forums building web sites without even
using the WHERE clause.

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
M. Strobel  
View profile  
 More options Feb 10, 5:12 am
Newsgroups: comp.lang.php
From: "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
Date: Fri, 10 Feb 2012 11:12:09 +0100
Local: Fri, Feb 10 2012 5:12 am
Subject: Re: Query or Array functions
Am 10.02.2012 02:18, schrieb Scott Johnson:

I think 5000 records is not much, nowadays.

We have sortable tables with client side scripting, why not filter the records with
client side scripting?

Requirement: solid knowledge of JavaScript.

/Str.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Captain Paralytic  
View profile  
 More options Feb 10, 5:44 am
Newsgroups: comp.lang.php
From: Captain Paralytic <paul_laut...@yahoo.com>
Date: Fri, 10 Feb 2012 02:44:03 -0800 (PST)
Local: Fri, Feb 10 2012 5:44 am
Subject: Re: Query or Array functions
On Feb 10, 1:18 am, Scott Johnson <nooneh...@chalupasworld.com> wrote:

If you're going to g the ajax route, I can recommend
http://www.sencha.com/products/extjs/. You will find an example there
that does almost exactly what you are talking about.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas 'PointedEars' Lahn  
View profile  
 More options Feb 10, 6:06 am
Newsgroups: comp.lang.php
Followup-To: comp.lang.php
From: Thomas 'PointedEars' Lahn <PointedE...@web.de>
Date: Fri, 10 Feb 2012 12:06:52 +0100
Local: Fri, Feb 10 2012 6:06 am
Subject: Re: Query or Array functions

Scott Johnson wrote:
> The problem I see is the numerous DB queries and I don't see querying
> the DB each time the user types a letter as a practical approach. (I
> could be wrong).

You do not have a PHP problem unless you are using PHP client-side.  Start a
client-side timer that must reach zero before the request is made that
invokes the database query server-side.  Reset it when the user types a
second character into the form control.  It has been done before.

> What I was thinking of doing is loading the full record set into an
> array and then filter out the array of the needed data as the user types.

That might be feasible if the original data was not modified after retrieval
and it was not too large for the client system to process.  In all other
cases you want to do the filtering server-side.

> I have not done any intense array manipulations like this before and am
> wondering if this seems like a practical approach.

You would not be manipulating *PHP* arrays (but see above), so …

PointedEars
--
When all you know is jQuery, every problem looks $(olvable).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas 'PointedEars' Lahn  
View profile  
 More options Feb 10, 6:32 am
Newsgroups: comp.lang.php
Followup-To: comp.lang.php
From: Thomas 'PointedEars' Lahn <PointedE...@web.de>
Date: Fri, 10 Feb 2012 12:32:32 +0100
Local: Fri, Feb 10 2012 6:32 am
Subject: Re: Query or Array functions

Thomas 'PointedEars' Lahn wrote:
> Scott Johnson wrote:
>> What I was thinking of doing is loading the full record set into an
>> array and then filter out the array of the needed data as the user types.

> That might be feasible if the original data was not modified after
> retrieval and it was not too large for the client system to process.
> In all other cases you want to do the filtering server-side.

That is, in the database query (`… WHERE …').  If you do not want to rely on
the client-side (i. e., have it to work without XHR as well) and do not care
if your displayed data reflects that currently in the database, you could
also store the unfiltered query result in the session, provided your session
storage can grow large enough without a relevant performance penalty on
access.

>> I have not done any intense array manipulations like this before and am
>> wondering if this seems like a practical approach.

> You would not be manipulating *PHP* arrays (but see above), so …

If you would store the query result as a PHP array in $_SESSION, then you
could use PHP array filtering functions on the array element of $_SESSION.

<http://php.net/session>

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
  -- Richard Cornford, cljs, <f806at$ail$1$8300d...@news.demon.co.uk>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Johnson  
View profile  
 More options Feb 10, 8:43 am
Newsgroups: comp.lang.php
From: Scott Johnson <nooneh...@chalupasworld.com>
Date: Fri, 10 Feb 2012 05:43:02 -0800
Local: Fri, Feb 10 2012 8:43 am
Subject: Re: Query or Array functions
On 2/10/2012 3:06 AM, Thomas 'PointedEars' Lahn wrote:

Man I never even considered the possible data change in which with using
preloaded arrays the page would have to be reloaded to update the data.
  So that alone is a deal breaker for the array method.

Thanks for the different look.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Johnson  
View profile  
 More options Feb 10, 8:54 am
Newsgroups: comp.lang.php
From: Scott Johnson <nooneh...@chalupasworld.com>
Date: Fri, 10 Feb 2012 05:54:03 -0800
Local: Fri, Feb 10 2012 8:54 am
Subject: Re: Query or Array functions
On 2/9/2012 5:39 PM, Michael Fesser wrote:

Thanks Micha

You bring up a great issues to the idea of accessing the data without a
separate page load.  The data would need to be loaded into a session to
be accessible with subsequent calls to the server w/o calling an entire
page load.

Not sure how loading a large data set into a session would affect
performance.  I know 5000 records is not all the large in the big
picture of large things but I like to 'try' to think ahead to larger issues.

But Thomas brought up a good point of data being modified after the
initial page load would not be represented any longer.  So I think the
separate data scheme is not a feasible solution any longer.

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Johnson  
View profile  
 More options Feb 10, 9:01 am
Newsgroups: comp.lang.php
From: Scott Johnson <nooneh...@chalupasworld.com>
Date: Fri, 10 Feb 2012 06:01:08 -0800
Local: Fri, Feb 10 2012 9:01 am
Subject: Re: Query or Array functions
On 2/10/2012 12:26 AM, "Álvaro G. Vicario" wrote:

Yeah I was thinking that it would take more processing to use a separate
data set, filter it, reorder it and then display a subset of that would
be a bit cumbersome.

Thomas brought up a good idea to use a timer between key presses that
would limit the queries to a time separation if the user types fast.

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Johnson  
View profile  
 More options Feb 10, 9:01 am
Newsgroups: comp.lang.php
From: Scott Johnson <nooneh...@chalupasworld.com>
Date: Fri, 10 Feb 2012 06:01:50 -0800
Local: Fri, Feb 10 2012 9:01 am
Subject: Re: Query or Array functions
On 2/10/2012 2:44 AM, Captain Paralytic wrote:

Hmmm.  Very worth a deeper look.  Thanks for the resource.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Captain Paralytic  
View profile  
 More options Feb 10, 9:11 am
Newsgroups: comp.lang.php
From: Captain Paralytic <paul_laut...@yahoo.com>
Date: Fri, 10 Feb 2012 06:11:55 -0800 (PST)
Local: Fri, Feb 10 2012 9:11 am
Subject: Re: Query or Array functions
On Feb 10, 2:01 pm, Scott Johnson <nooneh...@chalupasworld.com> wrote:

You can couple it with:
http://php-ext.quimera-solutions.com/

(not that I have used that bit yet)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jerry Stuckle  
View profile  
 More options Feb 10, 9:26 am
Newsgroups: comp.lang.php
From: Jerry Stuckle <jstuck...@attglobal.net>
Date: Fri, 10 Feb 2012 09:26:50 -0500
Local: Fri, Feb 10 2012 9:26 am
Subject: Re: Query or Array functions
On 2/10/2012 8:54 AM, Scott Johnson wrote:

Whether the data are in a session or not has nothing to do with whether
the page is loaded or not.  If the data reside on the server (whether in
the database or the session variable), it will take a request to the
server (either a page load or ajax) to access the data.  If the data are
on the client, no request to the server is required.

> Not sure how loading a large data set into a session would affect
> performance. I know 5000 records is not all the large in the big picture
> of large things but I like to 'try' to think ahead to larger issues.

Significantly.

> But Thomas brought up a good point of data being modified after the
> initial page load would not be represented any longer. So I think the
> separate data scheme is not a feasible solution any longer.

> Thanks

Too many variables to say for sure.  It might be ok for a shopping cart,
for instance.  But not for lap times in a car race.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas 'PointedEars' Lahn  
View profile  
 More options Feb 10, 6:03 pm
Newsgroups: comp.lang.php
Followup-To: comp.lang.php
From: Thomas 'PointedEars' Lahn <PointedE...@web.de>
Date: Sat, 11 Feb 2012 00:03:11 +0100
Local: Fri, Feb 10 2012 6:03 pm
Subject: Re: Query or Array functions

Scott Johnson wrote:
> On 2/10/2012 2:44 AM, Captain Paralytic wrote:
>> If you're going to g the ajax route, I can recommend
>> http://www.sencha.com/products/extjs/. You will find an example there
>> that does almost exactly what you are talking about.

> Hmmm.  Very worth a deeper look.  Thanks for the resource.

Because of its *ext*ensive size and potential compatibility issues due
to browser sniffing, you should only use ExtJS for an intranet desktop
application.  I happen to have helped built such a monster last year,
with ExtJS for the frontend and Zend Framework and MySQL on the backend.

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
)  // Plone, register_function.js:16


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gregor Kofler  
View profile  
 More options Feb 11, 5:03 am
Newsgroups: comp.lang.php
From: Gregor Kofler <use...@gregorkofler.com>
Date: Sat, 11 Feb 2012 11:03:44 +0100
Local: Sat, Feb 11 2012 5:03 am
Subject: Re: Query or Array functions
Am 2012-02-11 00:03, Thomas 'PointedEars' Lahn meinte:

> Scott Johnson wrote:

>> On 2/10/2012 2:44 AM, Captain Paralytic wrote:
>>> If you're going to g the ajax route, I can recommend
>>> http://www.sencha.com/products/extjs/. You will find an example there
>>> that does almost exactly what you are talking about.

>> Hmmm.  Very worth a deeper look.  Thanks for the resource.

> Because of its *ext*ensive size and potential compatibility issues due
> to browser sniffing, you should only use ExtJS for an intranet desktop
> application.  I happen to have helped built such a monster last year,
> with ExtJS for the frontend and Zend Framework and MySQL on the backend.

Sounds like pimcore. Had to do some minor adjustments on an
ExtJS-MVC-Application (with Coldfusion backend) - pretty atrocious.

Gregor


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas 'PointedEars' Lahn  
View profile  
 More options Feb 11, 6:06 am
Newsgroups: comp.lang.php
Followup-To: comp.lang.php
From: Thomas 'PointedEars' Lahn <PointedE...@web.de>
Date: Sat, 11 Feb 2012 12:06:42 +0100
Local: Sat, Feb 11 2012 6:06 am
Subject: Re: Query or Array functions

Gregor Kofler wrote:
> Thomas 'PointedEars' Lahn meinte:
>> Scott Johnson wrote:
>>> On 2/10/2012 2:44 AM, Captain Paralytic wrote:
>>>> If you're going to g the ajax route, I can recommend
>>>> http://www.sencha.com/products/extjs/. You will find an example there
>>>> that does almost exactly what you are talking about.
>>> Hmmm.  Very worth a deeper look.  Thanks for the resource.

>> Because of its *ext*ensive size and potential compatibility issues due
>> to browser sniffing,

… and UI built completely by client-side scripting instead of building on
HTML (not accessible or search-engine friendly) …

>> you should only use ExtJS for an intranet desktop application.  I happen
>> to have helped built such a monster last year, with ExtJS for the
>> frontend and Zend Framework and MySQL on the backend.

> Sounds like pimcore.

No, it was a custom built-from-scratch hardware management application for
the intranet of a multinational corporation.  Not my idea.

> Had to do some minor adjustments on an ExtJS-MVC-Application (with
> Coldfusion backend) - pretty atrocious.

ACK.

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
  -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter H. Coffin  
View profile  
 More options Feb 11, 12:20 pm
Newsgroups: comp.lang.php
From: "Peter H. Coffin" <hell...@ninehells.com>
Date: Sat, 11 Feb 2012 11:20:36 -0600
Local: Sat, Feb 11 2012 12:20 pm
Subject: Re: Query or Array functions

On Fri, 10 Feb 2012 09:26:21 +0100, ?lvaro G. Vicario wrote:
> If you are worried about retrieving matching rows from a 5000 row DB
> table using a SQL query, I doubt that using a file to store a serialized
> 5000 element bi-dimensional array and looping though it to find matches
> will be faster; not to mention the mess of keeping data up-to-date and
> taking care of concurrent access.

Kinda depends on the application. A reasonable reason to load 5000 rows
into a structure would be if you're doing some really fast lookups and
you have the memory to spare for it. A place that you might be wanting
to do that is a custom ETL tool for a single process. Pull data from
tape, update old codes to new codes on the fly, store data in a
database. Sure, you can DO it in the database with a salting of joins
and ALTERs, but if you're already getting the data out of something that
needs a program to do it anyway, why not fix it on the fly?

HOWEVER, that's a really specialized case. The vast amjority of the
time, you're not going to know that you're probably going to need the
whole table, and you're going to be way better off letting a database
engine manage it. What you're actually doing may actually only end up
needing a few hundred rows, and the DB will very quickly have those in a
cache and accessible for very little overhead. In which case, you're
moving far less data off of the disk (which is achingly slow in
comparison to fetching the same data from a cache, even layers deep),
and your net result is much more speed. The cache resources are going to
be allocated and used ANYWAY already, so you're not even "using less" by
neglecting the DB.

> A 10,000,000 record table is a big table. A 5,000 record table is not.
> Just make sure that your SQL knowledge goes beyond "SELECT * FROM foo".
> I've seen too many amateurs in forums building web sites without even
> using the WHERE clause.

"SELECT *" is "shovelling too much data", similar to above, even in
addition to how much trouble gets caused when someone comes along and
sticks another column onto the front of the record layout in a few
years.

And EVERY table ends up being used far longer than anyone ever expects.
My SO's senior project for a college course is still out there after
most of a decade, doing its thing, and is actively used by a couple of
hundred people a month.

--
Technical points aside, you could probably beat someone to
death with a Newton if you had to.  Try that with a Palm Pilot!
                              --Dan Duncan in comp.sys.newton.misc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »