Re: sequential disk read speed

From: David BL <davidbl_at_iinet.net.au>
Date: Sun, 24 Aug 2008 19:29:33 -0700 (PDT)
Message-ID: <398da625-540d-4bd9-b174-2b5c10c4e62b_at_m73g2000hsh.googlegroups.com>


On Aug 24, 1:26 am, Darren <anon5..._at_yahoo.com> wrote:
> On Aug 21, 12:08 am, David BL <davi..._at_iinet.net.au> wrote:
>
>
>
>
>
> > On Aug 21, 8:36 am, Darren <anon5..._at_yahoo.com> wrote:
>
> > > I am learning about database systems, and I am reading a book called
> > > "Physical Database Design".
>
> > > It gets to a bit about a large sequential access (e.g. for a full
> > > table scan), and does the following:
>
> > > It says "Since most disk systems use prefetch buffers to speed up
> > > table scans, we
> > > assume a 64 KB prefetch block"
>
> > > So to calculate the time for a full table scan, it multiples the
> > > number of 64KB blocks by the time it takes to seek and read (2.02ms).
> > > In other words, it is seeking each 64KB block.
>
> > > Why can a disk only read 64KB at a time? Is this a valid assumption?
> > > Is this a disk limitation or a file system limitation?
>
> > A high end modern HD with 4ms average seek will on average take about
> > 7ms to access and an additional 0.5ms to read a randomly located 64k
> > buffer. This mismatch shows that 64k blocks are too small for
> > optimal read performance. 512k or 1Mb blocks would be more suitable
>
> But what dictates the block size? Is this defined by the physical
> disk, the file system, or the database code?

As far as a physical disk is concerned the term “block” was commonly used to refer to the intersection of a sector and a track, but now days “sector” tends to be used instead. It is the smallest unit of reading/writing and is often 512 bytes. Some disks use 1024 byte sectors.

A file system provides buffering, and that allows an application to seek within a file and read/write a single byte. However behind the scenes an entire sector must be read/written to disk.

Typically a DBMS will read/write the disk without file buffering provided by the OS. For example on Win32, the function CreateFile can take the parameter FILE_FLAG_NO_BUFFERING. This forces the DBMS to work at the granularity of sectors – and it’s fairly low level. Eg there is a requirement that memory buffers be aligned on 512 byte boundaries to comply with the DMA constraints.

To avoid excessive seeking the DBMS will tend to organise the store into much courser units that are typically called “blocks”. The block size is up to the DBMS, but in practise will always be a multiple of a sector. In some cases it may relate back to track or cylinder boundaries, but that constraint is not imposed by the disk controller (which will happily allow for random access to any sector). Received on Mon Aug 25 2008 - 04:29:33 CEST

Original text of this message