# Presentation: D272Z3EGA77PJ26A46F56OJVK5UIZKV3

## High-Speed Access for an 

- NVO Data Grid Node

- María A. Nieto-Santisteban, Aniruddha R. Thakar, Alex Szalay, Tanu Malik,
*The Johns Hopkins University**  *
- Jim Gray
*Microsoft Research*

- Sloan Digital Sky Survey

- name/org/meeting

- Date

## Sloan Digital Sky Survey

- Digital map in 5 spectral bands covering 1⁄4 of the sky.
- Will obtain 40 TB of raw pixel data.
- Photometric catalog with more than 200 million objects.
- Spectra of 1 million objects.
- Data Release One – DR1: 6 TB of images, 200 k spectra.

- name/org/meeting

- Date

## The SkyServer Database

- Processed data is stored into a relational database, **SkyServer**.
- Allows fast exploration and analysis of the data (Data Mining).
- DR1 data base (Best + Target): ~ 1TB  and 6TB for final release.
- Heavily indexed to speed up access.
- Short queries can run interactively.
- Long queries (> 1 hour) require a custom Batch Query System.
- DBMS, Microsoft SQL Server 2000.

- name/org/meeting

- Date

## SkyServer Database Schema

**Meta**

**Spectro**

**Photo**

- name/org/meeting

- Date

## SkyServer and the NVO

- name/org/meeting

- Date

##  Partitioning and Parallelization

*Goals*
- Speed up query execution:
- Queries looking at different parts of the sky are distributed among  servers.
- Queries covering wide areas are executed in parallel by different servers. (Sequential scans fall naturally in this range)
- Neighborhood queries are “isolated” and processed in parallel.
- 	(Gravitational lenses and Galaxy clusters)
- Speed up cross-match requests from other NVO data nodes.

- name/org/meeting

- Date

## Partitioning Facts

*Partitioning works well if tables in the database are naturally divisible into similar partitions where most of the rows accessed by any SQL statement can be placed on the same member server.*

*Partitioning is most effective if the tables in the database can be partitioned symmetrically. (Not exactly our case)*

*Related data should be placed on the same member server so most SQL statements routed to a member will require minimum data from other servers.*

*Data should be partitioned uniformly across the member servers.*

- Designing Partitions.  Microsoft SQL Server Books Online

- name/org/meeting

- Date

## Partitioning Strategy

- Two-Step Process
- Distribute data homogenously among servers.
- Each server has roughly the same amount of objects.
- Objects inside servers are spatially related.
- Balances the workload among servers.
- Queries redirected to the server holding the data.
- (Re)Define zones inside each server dynamically.
- Zones are defined according to some search radius to solve specific problems:
- Finding Galaxy Cluster,
- Gravitational Lenses, etc.
- Facilitates cross-match queries from other NVO data nodes.

- name/org/meeting

- Date

## Mapping the Sphere into Zones

- In principle, h can be any number. In practice, 30 arcsec. (DR1 => 8000 ZONES)
- South-pole zone = Zone 0.
- Each object belongs to one Zone:
- ZoneID = floor ( (dec + 90) / h )
- Each server holds N “contiguous” Zones.
- N is determined by the number of objects that each Zone contains and the number of servers in the cluster.
- Not all servers contain the same number of zones.
- Not all servers cover the same declination range.
- Straightforward mapping between queries and servers.

- name/org/meeting

- Date

## Cone Searches using Zones

- Restrict search on dec to
- dec(dec - r), (dec + r)]
- Restrict search on ra to
- ra(ra-r)/(cos( |dec| ) + ), (ra+r)/(cos( |dec| ) + )] 1 e-6
- Filter on distance
-  ( (cx – x)2 + (cy – y) 2 + (cz – z) 2 ) < r

- ConeSearch  (ra, dec, r)
- Need to search only on zones between:
- maxZone = ceiling ((dec + 90 + r)/ h)
- minZone  =    floor ((dec + 90 – r)/ h)

- name/org/meeting

- Date

## Cone Searches using Zones

- Restrict search on dec to
- dec(dec - r), (dec + r)]
- Restrict search on ra to
- ra(ra-r)/(cos( |dec| ) + ), (ra+r)/(cos( |dec| ) + )] 1 e-6
- Filter on distance
-  ( (cx – x)2 + (cy – y) 2 + (cz – z) 2 ) < r

- ConeSearch  (ra, dec, r)
- Need to search only on zones between:
- maxZone = ceiling ((dec + 90 + r)/ h)
- minZone  =    floor ((dec + 90 – r)/ h)

- name/org/meeting

- Date

## Margins & Buffers

- To improve queries around Ra = 0 (or 360):
- Duplicate objects inside Ra = [-1, 0) and Ra = (360, 361] facilitates searches.
- Objects in the margin area are marked as Margin.

- To guarantee that neighboring searches can be fully satisfied inside a single server some zones are replicated:
- Each server adds 2 extra buffer regions of height RM
- RM,  is the maximum neighboring distance we assume (1 degree).
- Objects in buffers are “marked” as Visitors  to the Server.

- name/org/meeting

- Date

## Zoning Performance

- Time vs Search Radius for Cone Search searches

- 7x faster than using external calls to the HTM functions

- name/org/meeting

- Date

## Partitioning Process

**Generate partitions (n_servers, n_buffers)**
- Calculate the number of objects included on each Zone, Nz.
- Compute the accumulated distribution of objects , A, for each Zone. AZi = Sum (Nzi), i = 1 .. i
- Assign the 100/n_servers % of objects to each server.
- Add to each server the buffer zones.
- Add margin objects.
- Output:
- ServerZones (ServerId, ZoneID, objID, ra, dec, x, y, z, wrap, native, ...) Indexed by ZoneID and objID for fast access!
- Servers (ServerID, nObj, minZoneID, maxZoneID, overlapMinZoneID, overlapMaxZoneID, minDEC, maxDEC)
- Transfer data from main server to cluster members.

- name/org/meeting

- Date

## Data Transfer: Main Server - Nodes

- Replicate the database schema on each server to maintain relationships between tables.
- Member servers pull data from the main server using the ServerZones table.
- Can be done in parallel.
- Easier for the transaction manager.
- Asymmetric partitioning:
- Replicate most of the tables on each server.  It makes it easier and faster.
- Partition PhotoObjAll and SpecObjAll ... maybe others.
- Rebuild indexes.

- name/org/meeting

- Date

## Routing Rules Definition

- Determine where to send a query.
- Need a parser to capture regions requests like POINT, CIRCLE, REC, POLY ... etc. (Reuse parser from SkyQuery.)
- Once we have a declination, (or x,y,z)
** ****server =    SELECT ServerID **
**              ****	**** ****FROM   Servers **
**	****	**** ****WHERE ( obj.dec  BETWEEN minDEC AND maxDEC )**
- Queries without positional constrains mean full table scans and have to be sent to all nodes to be processed in parallel.

- name/org/meeting

- Date

## Building Neighborhoods

- Computing neighborhoods is computationally-intensive.
- Nested loop where for each object all neighbors inside some radius are computed.
- For completeness @deltazone = {-1, 0, 1}

- insert      neighbors				   -- insert one zone's neighbors
- select 	o1.objID as objID, 			   -- object pairs
- 	       o2.objID as NeighborObjID,
- from        zone o1 join zone o2 			    -- join 2 zones
- 	 on   o1.zoneID - @deltaZone = o2.zoneID               -- using zone number and ra
-    	 and o2.ra between o1.ra - @r and o1.ra + @r          -- points near  ra
- where 					                  -- elided margin logic
-   and o2.dec between o1.dec - @r and o1.dec + @r        -- quick filter on dec
-   and sqrt  ( power(o1.x - o2.x, 2) + power(o1.y - o2.y, 2) + power(o1.z - o2.z, 2))
-          < @r 					   -- careful filter on distance

- name/org/meeting

- Date

## Building Neighborhood Performance

- Results for Personal SkyServer (154k rows)
- Build Zone table:	  9.483 s
- Join to Zone -1:	10.487 s	generated 128,469 rows
- Join to Zone   0:	16.513 s	generated 389,157 rows
- Join to Zone   1:	  9.433 s	generated 126,104 rows
- Add mirror rows:	10.723 s	Total = 1,287,460  rows
- Create the index:	  7.563 s
- Total time			64.203 s
- For DR1, computing the neighbor table  (30”) took 2 days instead of 2 weeks.
- The overall improvement has been 32x faster than using external calls to the HTM functions.
- Can be done in Parallel!

- name/org/meeting

- Date

## Neighborhoods best Performance

- Building Neighborhoods performs best when the zone height is equal to the radius of the neighborhood.

- small radius imply joins with two or more northern zones and two or more southern neighbors.

- Tall zones require many more pairs and the work rise quadraticly.

- name/org/meeting

- Date

## Neighborhoods best Performance

- Building Neighborhoods performs best when the zone height is equal to the radius of the neighborhood.

- the center zone requires just a join with the upper and southern zones. A box of 3r x 2r.

- name/org/meeting

- Date

## Zones and Cross-Match

- 2MASS

- SDSS

- GALEX

- Applying a zoning  approach to other surveys makes JOINs a faster process.

- name/org/meeting

- Date

## Do the actual partitioning of SkyServer. Test it and measure performance.
So far we have “played” with MySkyServer a subset of DR1 with 1.3 GB.
Test with the finding galaxy cluster algorithm to compare against current grid approach.
Connect our databases to do the high computational processing on the GRID.

- So far we have “played” with MySkyServer a subset of DR1 with 1.3 GB.
- Test with the finding galaxy cluster algorithm to compare against current grid approach.
- Connect our databases to do the high computational processing on the GRID.

- Work to do

- name/org/meeting

- Date

##   To allow interactive exploration and  visualization of the data and do new discoveries!

	Any time left for the Image Cutout demo?
It takes 5 minutes.

- 	Any time left for the Image Cutout demo?
- It takes 5 minutes.

- After all ... Why High-Speed Access?

- name/org/meeting

- Date