I examine here an aspect of law enforcement that has recently been the subject of debate. This is the choice of a profiling policy wherein decisions to search for evidence of crime may vary with observable covariates of the persons at risk of being searched. Policies that make search rates vary with personal attributes are variously defended as essential to effective law enforcement and denounced as unfair to classes of persons subjected to relatively high search rates. Variation of search rates by race has been particularly controversial (see e.g., John Knowles et al., 2001; Nicola Persico, 2002; Jeff Dominitz, 2003). Whereas recent research on profiling has sought to define and detect racial discrimination, my concern is to understand how a social planner might choose a profiling policy. This paper studies optimal profiling in a simple, illustrative setting. In related work (Manski, 2004), I consider how a planner might reasonably behave when he does not possess all of the information needed to determine an optimal policy. Section I poses a utilitarian planning problem whose objective is to minimize the social cost of crime and search. Search is costly per se, and search that reveals a crime entails costs for punishment of offenders. Search is beneficial to the extent that it deters or prevents crime. Deterrence is expressed through the offense function, which describes how the offense rate of persons with given covariates varies with the search rate applied to these persons. Prevention occurs when search prevents an offense from causing social harm. Section II derives the optimal profiling policy in the tractable case where search deters crime linearly. One might think that search should focus on the most crime-prone segments of the population. However, this is not necessarily the case if persons differ in the extent to which search deters crime. It may be optimal to search a less crime-prone group and not to search a more crime-prone group if members of the former group are deterrable and those in the latter group are not. Sections I and II consider ex ante search, which apprehends offenders before their offenses cause social harm. Section III performs parallel analysis for ex post search, which apprehends offenders after completion of their offenses. Whereas ex ante search both deters and prevents crime, ex post search only deters. The two types of search have different implications for profiling policy. Although detection of discrimination is not my direct concern, the findings reported here do have implications for that inferential problem. The models studied in Knowles et al. (2001) and Persico (2002) imply that, in the absence of discrimination, optimal profiling must equalize the offense rates of persons with different covariates, provided that such persons are searched at all. The present model differs from theirs, and it does not produce their conclusion. Perhaps the most important difference is in the objective functions assumed for the agencies that make profiling policy. They assume that police on the street aim to maximize the probability of successful searches minus the cost of performing searches. I assume that a planner wants to minimize a social cost function with three components: (a) the harm caused by completed offenses, (b) the cost of punishing offenders who are apprehended, and (c) the cost of performing searches.