1. A method for optimizing a query requiring a join operation in a secure data access environment in a data processing system, the method comprising: providing a relational database having a first table and a second table, wherein a sensitive attribute serves as subset of a primary key for the first and second tables; receiving a query statement requiring a join operation of the first table and the second table, the query statement including authentication credentials; in response to determining that the authentication credentials allow only a masked access security view to the sensitive attribute: generating a first security view, the first security view granting a user access to the sensitive attribute values of the first table in a masked format, wherein the masked format value is generated from an unmasked format value using a reversible function; generating a second security view, the second security view granting the user access to the sensitive attribute values of the second table in a masked format, wherein the masked format value is generated from an unmasked format using a reversible function; generating an optimized query statement by rewriting the query statement using an inverse function of the reversible function to simplify the query statement; and performing the join operation between the first view and the second view by executing the optimized query statement.