Profile

outlier_lynn: (Default)
outlier_lynn

January 2015

S M T W T F S
    123
45678910
11121314151617
181920 21222324
25262728293031

Most Popular Tags

Expand Cut Tags

No cut tags
Wednesday, September 29th, 2004 09:32 am
I was playing this morning with my galleries database. The gallery_info procedure makes two calls to the database. One if speedy. The other is slow. WAY TOO SLOW and I make that call every single time the script runs. I use roughly the same procedure in both the admin (edit) scripts and in the public (display only) scripts.

The data it returns is static in the public scripts. it never changes. And it is coming back out of the database. I'll have the edit scripts write out a flat file (no more than 200 lines) that contain the four bits of information I need. Reading that file into the script and parsing the lines is fast.

I see no way to speed up the slow gallery_info query.

I'm reading the lines in and creating a list of lists. I like those, but they seem a little difficult to manipulate: "lindex [lindex $index 0] 0]" gets me the first item in the inside list from the first item in the master list. That will be a lot of calls to lindex.

Also, I keep forgetting that "read" doesn't get a line. To get a line, I have to "split [read file] \n]. I don't mess with files enough to remember that.

Creating the list of lists looks like this:
foreach line [split [read $file_handle] \n] {lappend index [split $line | ] }
Then getting the data from the first object looks something like this:
set name [lindex [lindex $index 0] 0]
set fp [lindex [lindex $index 0] 1]
set vis [lindex [lindex $index 0] 2]
set caption [lindex [lindex $index 0] 3]