Flat file "database"


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Flat file "database"
# 15  
Old 11-23-2010
relational databases handled sorted data and range based queries very nicely if the structures are designed well. For large amounts(hundreds of gigabytes or many terabytes of data you can partition the data by range and or by a key. I have not done this with MySQL but I know it works very well with DB2.

Check this out. It does not look difficult to implement in MySQL. I think it's worth a try since your already familiar with MySQL.
MySQL :: MySQL 5.1 Reference Manual :: 18.2 Partitioning Types
# 16  
Old 11-25-2010
Quote:
Originally Posted by Corona688
..., since a shell can't seek.
The kornshell 93 is capable to seek in a file for some time now. Here is an example:

First a simple file. Every line is 7 bytes long (including the newline character):

Code:
line 1
line 2
line 3
line 4
line 5

Here we go:

Code:
$ read VAR < file <# ((14))
$ print $VAR
line 3
$ read VAR < file <# ((7))
$ print $VAR
line 2

Or, if you do not want to reopen the file every time:

Code:
$ exec 3<file
$ read -u3 VAR 3<# ((21))
$ print $VAR
line 4
$ read -u3 VAR 3<# ((7))
$ print $VAR
line 2

Oops, just saw, that fpmurphy said that already, sorry for double post.

Last edited by hergp; 11-25-2010 at 05:31 AM..
# 17  
Old 11-25-2010
It's fine, more examples are always good! Smilie

That's interesting, file seeking was the one thing I always lacking in bash scripts... I wrote a little wrapper library for fopen/fclose/fscanf calls, but just couldn't do a real fseek in bash.
# 18  
Old 11-25-2010
Data sorted on primary key is ideal for bulk loading into mainstream databases. Though indexes take space the data retrieval performance should be good.
# 19  
Old 11-25-2010
The nicest key for bulk loaded data is time, append-only table. For interactive, it is better to mix it up (user, time) so all users are not fighting to insert to the same page, but you can stage it clustered one way and batch move it in near real time background.

No db beats the storage density of flat files, never mind compressed. That is why I suggested zip/unzip and file/dir partitioning. You can ask unzip to pick up 50 small compressed files by wild card path and write all the data uncompressed to stdout on a pipe to your app., which can be HXTT JDBC or the like. If you partition on several keys, you can search key by file name within zip archives for each day, week, month or year. With modern CPU speed, it may beat formal RDBMS not only on space but on speed!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

5. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

how to create flat file delimited by "\002"

I need to create a flat file with columns delimited by "\002" (octal 2) I tried using the simple echo. name="Adam Smith" age=40 address="1 main st" city="New York" echo ${name}"\002"${age}"\002"${address}"\002"${city} > mytmp but it creates a delimiter with different octal... (4 Replies)
Discussion started by: injey
4 Replies

8. Shell Programming and Scripting

"sed" to check file size & echo " " to destination file

Hi, I've modified the syslogd source to include a thread that will keep track of a timer(or a timer thread). My intention is to check the file size of /var/log/messages in every one minute & if the size is more than 128KB, do a echo " " > /var/log/messages, so that the file size will be set... (7 Replies)
Discussion started by: jockey007
7 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question