lets say i have a records about 4kb long but i need to read only specific field 30 bytes long.
Will i gain any perfomance/speed if i read ONLY 30 bytes and not the whole record?
I'm asking this because i read somewhere that filesystem retrieves data in chunks of 4kb(depending on allocation unit) and even if i read only single byte it is the same as read the whole chunk.
size of buffer and disk access times
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
it's highly dependant on how the file system does what it does. So unless we know the specifics of the file system you are concerned against, there's not much we can say. Some systems will read and keep the chunk in memory, copying out the bits being wished to read. Others will just read the part you want, throwing the rest back.
The block size varies wildly as well.. Plus there are things like page faults, cache misses, seek times and butterfly accesses to deal with.. so, my suggestion is don't worry about it as the file system is usually pretty solid.
If you are opening and closing a file all the time, you may want to make the file span all the accesses needed. Seeking in files can be slow.. loading the file into memory and parsing it is almost always faster..
The block size varies wildly as well.. Plus there are things like page faults, cache misses, seek times and butterfly accesses to deal with.. so, my suggestion is don't worry about it as the file system is usually pretty solid.
If you are opening and closing a file all the time, you may want to make the file span all the accesses needed. Seeking in files can be slow.. loading the file into memory and parsing it is almost always faster..
- Buddha443556
- Forum Regular
- Posts: 873
- Joined: Fri Mar 19, 2004 1:51 pm
I agree with everything Feyd said ... except:
Working mostly with shared servers I find the file system the biggest bottleneck. Maybe that would be what Feyd meant by "usually" though. I wouldn't worry so much about how you read the data but how you handle it as Feyd suggested.feyd wrote:so, my suggestion is don't worry about it as the file system is usually pretty solid.