I was looking into making queries for a particular file in a Bacula Postgres 
database,  and came up with the attached functions.  If someone really wanted 
to do searches by other attributes, it would be simple to follow the same 
pattern.  With the functions and functional indexes, a query like

SELECT bacula_lstat_mtime(lstat),path.path,filename.name
FROM file 
INNER JOIN path ON file.pathid=path.pathid \
INNER JOIN filename ON file.filenameid=filename.filenameid
WHERE bacula_lstat_mtime(lstat)<'2009-12-05 13:55'
ORDER BY bacula_lstat_mtime(lstat) DESC LIMIT 15

is really fast.

--
DLL

Attachment: pgbacula.sql
Description: Binary data

Attachment: Makefile
Description: Binary data

Attachment: pgbacula.c
Description: Binary data

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to